So I've been looking for a way to reconnect automatically to my wireless after I get dumped - I LOVE this Linksys, really I do, but for some reason I randomly get taken off my Wifi and unlike the old Dlink, we seem unable to automatically get back on when this happens.
Thanks to some Googling and this 2 year old blog post (osxdaily.com), I now have a root crontab entry which goes ahead and issues a connect every five minutes, whether I'm connected or not:
I COULD write something smarter which checks to see if I'm connected and then run the command only if I'm NOT connected, but a little overkill doesn't hurt here. Keep It Simple, Stupid. As near as I can tell, nothing happens when I try to connect to the network I'm already connected to - if there IS a break, it's not long enough for any of the programs I'm running to notice.
The hardest part was figuring out the Mac command line to connect to a Wifi network. Apple sure doesn't make it easy, burying that "airport" command deep down at /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport ...which is why the first thing you need to run is the "ln -s" command to make a symlink in a more convenient place, like /usr/sbin - this is in that blog post but I might as well reprint it here, too:
We have Vista, OS X and a Gentoo box in our home network, and everything seems to play nicely.
The random dumps I was experiencing with my old Linksys WRT54G router had to do with the media server of my PS3. For some reason, those two things didn't get along - but all of that seemed to resolve with both the change in router and the last PS3 update - so I haven't had any issues since.
Have you upgraded to the latest firmware for the WRT400N? For some reason, our router shipped with an older firmware installed - which is probably a result of purchasing on eBay.
Originally posted by LeroyHave you upgraded to the latest firmware for the WRT400N? For some reason, our router shipped with an older firmware installed - which is probably a result of purchasing on eBay.
What's on there (1.0.01 19, sayeth the diagnostic screen, IIRC) matches the version number of what's on the website. Apparently there's only ever BEEN the one version, which I thought was odd (no update since Dec 2008? Really?) but accepted.
Since I implemented that crontab, if I've been booted, I've been blissfully unaware.
OK, that doesn't work so well. I ran into a problem where I would end up taking the entire router down until I powercycled it - something to do with doing Time Machine between this one and the other one over the wireless but disconnecting/reconnecting and oh it got very frustrating. SO. HERE is a script which will try a ping first, and ONLY try to reconnect me in the event that the ping fails. I'm using the address of my router for the ping but something you expect to be up (like crz.net!) would work just as well.
I'm still using cron to call this script every five minutes.
Just for kicks, I also threw in a bit in there were it mails me when I do reconnect. Actually, it'll mail me anyway, but I want the return code, too, so I put an extra echo in there. ("$?" is the return code - 0 is success, nonzero is failure, OK, just in case you didn't know that)
#!/bin/sh /sbin/ping -c 1 192.168.1.1 > /dev/null 2>&1 a=`echo $?` case "$a" in 0) ;; *) echo $a ; /usr/sbin/airport -A --password= > /dev/null 2>&1 ;; esac
In retrospect, maybe "case $? in" would have worked - I thought it wasn't getting passed right, but what I had actually screwed up was putting "ping" instead of "/sbin/ping" because Mac's idea of Linux seems to require an awful lot of explicit paths (notice I put "/usr/sbin/airport" instead of "airport" as my earlier cron entry had - that earlier one probably wouldn't work on YOUR Mac, either) ahhhh I need to sleep. I'll post this now and look at it later. Hopefully when I wake up I'm still connected to the router automagically. :)
What a lineup of all-stars we have below 1999: Smackdown (slashwrestling.com) 1999: Thunder by Tom Cruz 1999: Thunder by mdb 1999: Thunder by Albert B. Ching 2000: WOW 2000: Worldwide by E.C. Ostermeyer 2001: Heat by The Cubs Fan 2001: