Does anyone have a good solution to returning the current AirPort network as an extension attribute that works on MacBook Pro and MacBook Air hardware?
The trouble I'm running into is that on a Lion machine, I can't get "AirPort" information from the "networksetup -getairportnetwork" if I don't designate en0 or en1 instead of using the common name of AirPort.
On the MBP and everything else, asking it to return results on en1 works fine because that generally is the AirPort interface. However, in MBAs (or other hardware that has the AirPort interface set to something else), all it will do is return an error.
Here's what I've been working with. And, yes, I did borrow most of it from an XML file I found in another post on JAMF Nation. :^)
#!/bin/sh
# Determine the OS version since the networksetup command differs on OS
OS=/usr/bin/sw_vers -productVersion | /usr/bin/colrm 5
if [[ "$OS" < "10.5" ]]; then
# Ensure that the networksetup link exists on 10.4 and earlier
if [ -f /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup ];then
result=/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -getairportnetwork | sed 's/Current AirPort Network: //g'
else
result=The networksetup binary is not present on this machine.
fi
elif [ "$OS" == "10.5" ]; then
result=/usr/sbin/networksetup -getairportnetwork | sed 's/Current AirPort Network: //g'
else
result=/usr/sbin/networksetup -getairportnetwork en0 | sed 's/Current AirPort Network: //g'
fi
# Ensure that AirPort was found
hasen0=echo "$result" | grep "Error"
# Report the result
if [ "$hasAirPort" == "" ]; then
echo "<result>$result</result>"
else
echo "<result>No AirPort Device Found.</result>"
fi
