Skip to content

Instantly share code, notes, and snippets.

@raine
Created July 2, 2014 12:43
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 raine/053755ca8545edec7fdb to your computer and use it in GitHub Desktop.
Save raine/053755ca8545edec7fdb to your computer and use it in GitHub Desktop.
#!/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
@ludzeller
Copy link

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment