Display Support info for end user

jebS
New Contributor III

Hello all - my first attempt at applescript (raised on windows - sorry-)

I created this script using data from the simple 'Get System Info' - It is supposed to display the user name that is logged in, computer name, ip address, and Mac address. - there is also a button to capture a screenshot for support purposes. I have it set as a policy so the user can run in self service to supply the info to the helpdesk. A few issues when run via self service:
1. Shows 'root' as logged in user - I'm guessing because casper runs under these credentials?
2. shows my mac address as my wifi connection mac address even though wifi is disabled,
3. shows my ipaddress as 'missing value' - which happens with wifi enabled or disabled.

does anyone know how I can pull this data from the current active network connection?

I did go over the following link: https://jamfnation.jamfsoftware.com/discussion.html?id=11243
but can't figure out how to add mac address to the solution scripts, and we cannot install any freeware solutions
I's appreciate any help.

osascript <<EOD
set user to short user name of (system info)
set nm to computer name of (system info)
set mac to primary Ethernet address of (system info)
set ip4 to IPv4 address of (system info)

display dialog "You are logged in as: " & tab & tab & user & return & "Computer name: " & tab & tab & tab & nm & return & "IP address: " & tab & tab & tab & tab & ip4 & return & "Mac address: " & tab & tab & tab & mac ¬ with icon file "System:Library:PreferencePanes:Network.prefPane:Contents:Resources:Network.icns" with title "System Information" buttons {"Screenshot", "OK"}

if result = {button returned:"Screenshot"} then tell application "System Events" keystroke (ASCII character 36) using {command down} key code 4 using {command down, shift down} end tell
end if
EOD

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

While I'm sure you could do all of this in Applescript, I'm not the best in it myself. I suggest trying to do a shell script that calls jamfHelper. I only suggest jamfHelper because of this in your original post:

we cannot install any freeware solutions

I assume this means you can't deploy something like cocoaDialog or such. Though I don't get why, you could use jamfHelper for the message since its deployed as part of the Casper Suite's toolset so its going to be on any managed Macs anyway.

Try the following script. I think this will do everything you outlined above.

#!/bin/sh

JHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

USERNAME=$(ls -l /dev/console | awk '{print $3}')
MACNAME=$(scutil --get ComputerName)
PORT=$(/usr/sbin/netstat -rn -f inet | awk '/default/{print $NF; exit}')
IPADDRESS=$(ipconfig getifaddr $PORT)
MACADDRESS=$(networksetup -getmacaddress $PORT | awk '{print $3}')

MESSAGE="You are logged in as:     $USERNAME
Computer name:          $MACNAME
IP Address:             $IPADDRESS
MAC Address:            $MACADDRESS"

THEMESSAGE=$("$JHELPER" -windowType utility -title "Disney System Information" -description "$MESSAGE" -button1 "OK" -button2 "Screenshot" -defaultButton 1 -icon "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericNetworkIcon.icns" -iconSize 64)

if [ "$THEMESSAGE" == "0" ]; then
    exit 0
elif [ "$THEMESSAGE" == "2" ]; then
    DATE=$(date +"%Y-%m-%d at%l.%M.%S %p")
    screencapture -t png "/Users/$USERNAME/Desktop/Screen Shot ${DATE}.png"
    chown ${USERNAME}:staff "/Users/$USERNAME/Desktop/Screen Shot ${DATE}.png"
    exit 0
fi

View solution in original post

4 REPLIES 4

millersc
Valued Contributor

In terminal this "networksetup -getmacaddress Wi-Fi" returns this:
Ethernet Address: 84:38:xx:xx:xx:xx (Hardware Port: Wi-Fi)
Now this is dependent on the name of the port. In my case it was "Wi-Fi". For your case it would be "Ethernet" if using the standard Apple naming convention. Use the man networksetup to get a lot more options.

mm2270
Legendary Contributor III

While I'm sure you could do all of this in Applescript, I'm not the best in it myself. I suggest trying to do a shell script that calls jamfHelper. I only suggest jamfHelper because of this in your original post:

we cannot install any freeware solutions

I assume this means you can't deploy something like cocoaDialog or such. Though I don't get why, you could use jamfHelper for the message since its deployed as part of the Casper Suite's toolset so its going to be on any managed Macs anyway.

Try the following script. I think this will do everything you outlined above.

#!/bin/sh

JHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

USERNAME=$(ls -l /dev/console | awk '{print $3}')
MACNAME=$(scutil --get ComputerName)
PORT=$(/usr/sbin/netstat -rn -f inet | awk '/default/{print $NF; exit}')
IPADDRESS=$(ipconfig getifaddr $PORT)
MACADDRESS=$(networksetup -getmacaddress $PORT | awk '{print $3}')

MESSAGE="You are logged in as:     $USERNAME
Computer name:          $MACNAME
IP Address:             $IPADDRESS
MAC Address:            $MACADDRESS"

THEMESSAGE=$("$JHELPER" -windowType utility -title "Disney System Information" -description "$MESSAGE" -button1 "OK" -button2 "Screenshot" -defaultButton 1 -icon "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericNetworkIcon.icns" -iconSize 64)

if [ "$THEMESSAGE" == "0" ]; then
    exit 0
elif [ "$THEMESSAGE" == "2" ]; then
    DATE=$(date +"%Y-%m-%d at%l.%M.%S %p")
    screencapture -t png "/Users/$USERNAME/Desktop/Screen Shot ${DATE}.png"
    chown ${USERNAME}:staff "/Users/$USERNAME/Desktop/Screen Shot ${DATE}.png"
    exit 0
fi

jebS
New Contributor III

Thanks mm2270

This is just what is needed. I appreciate the help

waqas
New Contributor III

Mike, you are "The Dude" :)

Thank you so much for sharing.