User Tools

Site Tools


info:mac:make_your_mac_feel_home
Please note, that this is an old archived version of this site. Check out the new version at andunix.net!

Make your Mac feel at Home

A small snippet from one of my scripts which tests whether your Mac is in the given (home) WLAN.

#
# Path to 'airport' executeable, as of Mac OS X 10.5.
AIRPORT="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
#
# Set this to your Home WLAN SSID (name):
HOMESSID="mycastle"
#
# Get SSID info from 'airport' and search for $HOMESSID
SSID=$(${AIRPORT} --getinfo | grep ' SSID:')
SSID=$(echo ${SSID} | grep "^SSID: ${HOMESSID}\$")
#
# Branch depending on grep's return code.
if [ "$?" == "0" ]; then
	# in home wlan
	echo "home sweet home..."
else
	# not at home
	echo "on the road again..."
fi

To use this code, set the HOMESSID to your SSID (the name of the wireless network) and replace the two echo lines with your code.

info/mac/make_your_mac_feel_home.txt · Last modified: 2015-11-25 08:53 by andunix