Skip to content

Instantly share code, notes, and snippets.

Created Jul 2, 2014
What would you like to do?
#!/usr/bin/env ruby
def wifi_connect(wifi, sid, pw)
out = `networksetup -setairportnetwork #{wifi} #{sid} #{pw}`
puts out
!(out =~ /could not find/i)
sid, pw = ARGV[0..1]
(wifi_connect("en0", sid, pw) and exit 0) while 1
Copy link

ludzeller commented Dec 14, 2017

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