Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically set location based on connected SSID' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically set location based on connected SSID
Authored by: sushigeek on Feb 23, '06 08:00:52PM
Instead of using system profiler, which can take a bit to run on some older Macs, I'd suggest using the following:

/System/Library/PrivateFrameworks/Apple80211.framework/ \
Versions/A/Resources/airport -I | grep '.* SSID:' | sed 's/^.* SSID: //'
N.B. For any unfamilar with AppleScript, please remember to use that as a single line -- without the space and backslash characters on the first line -- inside the script.

[ Reply to This | # ]
awk'd version
Authored by: sjk on Feb 23, '06 08:14:05PM
Here's a more compact version that uses awk:

airport -I | awk '/ SSID/ {print $2}'

[ Reply to This | # ]
awk'd version
Authored by: LakeSolon on Mar 13, '09 01:09:10PM
Tweaked the above so it would print the entire SSID even if it includes spaces -

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/ SSID/ {split($0, parts, ": "); print parts[2]}'

[ Reply to This | # ]

sed version
Authored by: kholburn on May 17, '06 08:59:04PM
Here's a more compact and faster version. sed is much smaller and faster than awk.

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | sed '/ SSID: /!d; s/^.* SSID: //'


[ Reply to This | # ]