Last active
August 29, 2015 13:57
-
-
Save douglasresende/9901932 to your computer and use it in GitHub Desktop.
Auto Connect Wifi Mac OS
This file contains 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/bash | |
# http://magp.ie/2012/07/09/mac-osx-shell-script-to-automate-connecting-to-wifi-network/ | |
AIRPORT="en1"; #may be en0, use networksetup -listallhardwareports to check | |
WIFI_NETWORK_NAME="nomedarede" | |
WIFI_PASSWORD="senhadarede" | |
SCRIPT_PATH="$(pwd)/wifi.sh" | |
if networksetup -getairportnetwork $AIRPORT | grep -i -a $WIFI_NETWORK_NAME ; | |
then | |
PROMPT_COMMAND='echo -ne "\033]0;"WIFI: OK"\007"' | |
else | |
PROMPT_COMMAND='echo -ne "\033]0;"WIFI: OFF"\007"' | |
osascript -e 'tell app "System Events" to display notification "WiFi OFF"' | |
networksetup -setairportnetwork $AIRPORT $WIFI_NETWORK_NAME $WIFI_PASSWORD | |
fi | |
sleep 10 | |
clear | |
sh $SCRIPT_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment