-
-
Save raine/053755ca8545edec7fdb to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
def wifi_connect(wifi, sid, pw) | |
out = `networksetup -setairportnetwork #{wifi} #{sid} #{pw}` | |
puts out | |
!(out =~ /could not find/i) | |
end | |
sid, pw = ARGV[0..1] | |
(wifi_connect("en0", sid, pw) and exit 0) while 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool stuff, am using this now.
I don't know ruby though... Would it be easy to make the script running permanently (just in the shell, not thinking about a daemon, etc) so that it would reconnect automatically after a disconnect (sleep, phone to far away etc)?