Created
March 19, 2017 14:16
-
-
Save lukem512/5657332868be3d6f098f7e96954a36df to your computer and use it in GitHub Desktop.
Toggle WiFi networks (OSX)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
ssid1="THEUNIVERSE" | |
pass1="yourpass" | |
ssid2="SPACE" | |
pass2="yourotherpass" | |
curr=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'` | |
echo Currently connected to $curr | |
echo Power cycling... | |
networksetup -setairportpower en0 off | |
networksetup -setairportpower en0 on | |
echo Power online, connecting... | |
if [ "$curr" == "$ssid1" ] | |
then | |
networksetup -setairportnetwork en0 $ssid2 $pass1 | |
else | |
networksetup -setairportnetwork en0 $ssid1 $pass1 | |
fi | |
echo Done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment