Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nemefist

macrumors newbie
Original poster
Dec 30, 2007
2
0
Alright heres the deal. I play an online game and am suffering from random internet freezes that require me to manually click on the Airport Icon and reconnect to my network in order to continue playing. I am looking for an apple script compatible with the Airport UI for the 10.5 OS X which pings my internet connection at certain time intervals and then and restarts the airport if a drop has happened. I found an applescript that would work, but it is for the 10.4 OS X. It is not friendly with the new UI of Leopard's Airport Utility. Basically I need a translation of this 10.4 script to become a 10.5 compatible script. I'm not very skilled in Applescript so I cannot do it myself. Please help.

Heres the script:

----------------------------------------------------------------------------------------------------------------------------
repeat
restartIfNecessary()
do shell script "sleep 300"
end repeat


on restartIfNecessary()
set s to "ping -c 1 -t 4 4.2.2.1 > /dev/null; echo $?"
set r to do shell script s

if r is equal to "0" then
dlog(((current date) as string) & " AirPort OK")
else
dlog(((current date) as string) & " AirPort down. Restarting.")
restartAirPort()
end if
end restartIfNecessary

on restartAirPort()
tell application "AppleScript Utility"
activate
delay 2
tell application "System Events"
tell window 1 of process "Internet Connect"
try
tell button "AirPort" of tool bar 1 to click
delay 2
end try

try
tell button "Turn AirPort Off" to click
delay 7
end try

try
tell button "Turn AirPort On" to click
delay 2
on error
try
tell button "Turn AirPort Off" to click
end try
end try
end tell
end tell

quit
end tell
end restartAirPort


on dlog(msg)
set t to ((path to temporary items) as string) & "AirPortRestarter.log"
set f to open for access file t with write permission

write msg & "
" to f starting at (get eof of f) + 1

close access f
end dlog

-------------------------------------------------------------------------------------------------------------------

I did not make this script, nor do I take credit for any part of this. Please help me with my issue!
 

Nemefist

macrumors newbie
Original poster
Dec 30, 2007
2
0
Did you update the Airport firmware? What about using ethernet cable?

Ethernet is not an option and yes, i did update it. I've tried everything but this, and this seems to be the only reasonable solution.
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
First off, Leopard doesn't have Internet Connect anymore, it was a really pointless program to begin with.

Secondly, you would have to get it so it's in System Preferences. The restartAirport() function is really poorly written for what you want, because no matter what, if an error occurs (I can't figure out what kind of error), it will keep Airport turned off, which is a nice safety feature, but not necessary. Now are you turning off Airport card from your computer off, or the base station/express?

Third, what would be the point of keeping a log of when it goes down? The only time it should go down is if what you are requesting in a game is far more than what the base station can handle.

It would be best to ask the author of the script to update it for Leopard, or learn it yourself (which I recommend since AppleScript is really quite easy to understand).
 

aforty

macrumors 65816
Nov 27, 2007
1,492
780
Brooklyn, NY
Did you post this one every Mac/WoW form you could find and pollute Google? Thanks.

If you get random disconnects look into getting a new router.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.