Sometimes I need to download very big files from the internet using torrents (I'm using Transmission) and the Wi-Fi always drops. I bought several routers and modems and none of them work. I've been having this issue a for a while (~10 years, with both Windows and Mac).
Now I decided to learn a bit, and write some AppleScript which reconnects automatically:
repeat
if (do shell script "curl --connect-timeout 1 <WIFI_IP>") = "curl: (7) couldn't connect to host" then
do shell script "networksetup -setairportpower AirPort off"
do shell script "networksetup -setairportpower AirPort on"
do shell script "networksetup -setairportnetwork en1 <ROUTER_NAME> <ROUTER_PASS>"
end if
end repeat
the part after then works, it disconnects from Wi-Fi and reconnects it, but the problem is with the if part, because I don't know how to detect when the Wi-Fi connection is broken by the torrent. How should I do this?
Also, a repeat with an interval would be really nice, something like: repeat every 10 seconds.
delay 300just before therepeat endto keep the script from constantly checking for a connection. 300 seconds would have it check every 5 mins. – Vickash Jan 3 '12 at 19:45