Skip to main content

Jamf published Build a Computer Information script for your Help Desk on the Jamf Blog this morning. In that post I used the term "module" to refer to a short script snippet that can read a piece of information from a Mac and display that information as part of a dialog shown to the end user.



For example, this gets the computer name:



# Display computer name
runCommand=$( /usr/sbin/scutil --get ComputerName )
computerName="Computer Name: $runCommand"




This Jamf Nation Discussion is for anyone who's needing assistance creating additional modules and/or helping others create modules.

@emily



Very nice info! Have you tried it? Trying to get the custom logo to work, but not sure how to make it work.


@fredrik.virding I haven’t used it myself yet but I can try to tuck aside some time this week and see what I can come up with. The Mac Admins Slack may be another good resource for tip or some feedback on how to use it.


@emily



Noted! The rest of the features was pretty straight forward. Super slick.


Hello everyone,
I'm new to scripting and this helpdesk script is really great.
On the other hand, I would like the Mac address to be found in addition to the IP address when this command is used.

networkServices=$( /usr/sbin/networksetup -listallnetworkservices | /usr/bin/grep -v asterisk )

while IFS= read aService
do
activePort=$( /usr/sbin/networksetup -getinfo "$aService" | /usr/bin/grep "IP address" | /usr/bin/grep -v "IPv6" )
if [ "$activePort" != "" ] && [ "$activeServices" != "" ]; then
activeServices="$activeServices\\n$aService $activePort"
elif [ "$activePort" != "" ] && [ "$activeServices" = "" ]; then
activeServices="$aService $activePort"
fi
done <<< "$networkServices"

activeServices=$( echo "$activeServices" | /usr/bin/sed '/^$/d')

After several hours of searching, I can't find the solution so I'm asking you for help.


Hello everyone,
I'm new to scripting and this helpdesk script is really great.
On the other hand, I would like the Mac address to be found in addition to the IP address when this command is used.

networkServices=$( /usr/sbin/networksetup -listallnetworkservices | /usr/bin/grep -v asterisk )

while IFS= read aService
do
activePort=$( /usr/sbin/networksetup -getinfo "$aService" | /usr/bin/grep "IP address" | /usr/bin/grep -v "IPv6" )
if [ "$activePort" != "" ] && [ "$activeServices" != "" ]; then
activeServices="$activeServices\\n$aService $activePort"
elif [ "$activePort" != "" ] && [ "$activeServices" = "" ]; then
activeServices="$aService $activePort"
fi
done <<< "$networkServices"

activeServices=$( echo "$activeServices" | /usr/bin/sed '/^$/d')

After several hours of searching, I can't find the solution so I'm asking you for help.


I finally found a solution. Here is the modified script :)

networkServices=$( /usr/sbin/networksetup -listallnetworkservices | /usr/bin/grep -v asterisk )

while IFS= read -r aService
do
activePort=$( /usr/sbin/networksetup -getinfo "$aService" | /usr/bin/grep "IP address" | /usr/bin/grep -v "IPv6" )
if [ "$activePort" != "" ] && [ "$activeServices" != "" ]; then
ipAddress=$(echo "$activePort" | /usr/bin/awk '{print $3}')
macAddress=$( /sbin/ifconfig | /usr/bin/grep -B2 "$ipAddress" | /usr/bin/awk '/ether/ {print $2}')
activeServices="$activeServices\\n$aService $activePort MAC: $macAddress"
elif [ "$activePort" != "" ] && [ "$activeServices" = "" ]; then
ipAddress=$(echo "$activePort" | /usr/bin/awk '{print $3}')
macAddress=$( /sbin/ifconfig | /usr/bin/grep -B2 "$ipAddress" | /usr/bin/awk '/ether/ {print $2}')
activeServices="$aService $activePort MAC: $macAddress"
fi
done <<< "$networkServices"

activeServices=$( echo "$activeServices" | /usr/bin/sed '/^$/d')

Reply