10.5: An AppleScript to restart an AirPort Base Station

Jan 04, '08 07:30:00AM

Contributed by: pokey

After reading my Airtunes hint, several people have asked me to post a script to restart an AirPort Base Station ... so here it is. The script assumes you can at least see the Base Station in AirPort Utility, which is not always the case so YMMV. You can use the launchd utility or Cronnix if you prefer to schedule it. If you have a shell script for this, please share as I think that would be a more elegant solution.

Meanwhile, here's the AppleScript:

--this script will restart the Airport base station in Leopard
--note there is a different script for Tiger

tell application "AirPort Utility" to activate
delay 2
tell application "System Events"
  tell application process "AirPort Utility"
    
    tell window 1
      click button "Manual Setup"
      delay 8
    end tell
    
    tell menu bar 1
      click menu bar item "Base Station"
      
      tell menu bar item "Base Station"
        tell menu 1
          click menu item "Restart…"
        end tell
      end tell
    end tell
    
    delay 1 --imperative
    
    tell window 1 --"AirPort Utility - Extreme Base"
      tell sheet 1
        click button "OK"
      end tell
    end tell
    
    say "Restarting Airport"
    
    delay 1
    
  end tell
end tell

tell application "AirPort Utility" to quit
[robg adds: I haven't tested this one.]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20071228144426216