Skip to content

Instantly share code, notes, and snippets.

@scott0228
Created July 25, 2012 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scott0228/3175681 to your computer and use it in GitHub Desktop.
Save scott0228/3175681 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 先取得 SSID
ssid=$(networksetup -getairportnetwork en1 | cut -c 24-)
# 依 SSID 決定要用哪個 location ,可利用 scselect 指令來列出所有的 location
if [ $ssid = "ScottAP" ]
then
location="Work"
else
location="Automatic"
fi
# 更新 location
newloc=`/usr/sbin/scselect ${location} | sed 's/^.*(\(.*\)).*$/\1/'`
echo ${newloc}
# 辨斷是否正確來回撌值
if [ ${location} != ${newloc} ]
then
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment