AppleScript for AirPort Control

Dear All

We are not permitted to have wireless systems active at our workplace. However, Mac laptop users who use wireless at home, may come into work with their AirPort still active. I’d like to write a login AppleScript which :

at a bare minimum:

  1. Checks to see if the Airport is active and alerts the user if it is.


  1. Checks to see if the AirPort is active. If it is
  2. Checks the current IP address - if it is one issued by our DHCP server automatically turn off AirPort and alert the user to what has happened.

I see that the Internet Connect AppleScript dictionary has AirPort commands ‘AirPort Configuration’ and ‘AirPort Power’ but try as I might I can not get access to these via Applescript.

Note, I wish to roll this out to many users, and so I do not wish to install additional third party additions or other additions. Any solution must be AppleScript as it comes out of the box in 10.4.10.

Is this possible?

Thanks in advance

Dave M

Model: MacPro
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Dave,

the easiest way is to create a new network location with Airport disabled (I called it AirportDisabled)
The script checks if Airport is on and the BSSID (MAC address) of the router.
If it’s the router at work, it switches to the AirportDisabled location

property workBSSID : "00:11:22:33:44:55"

set AirportData to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/(Off)|(BSSID)/ {print $2}'"
if AirportData is "Off" then
else if AirportData is workBSSID then
	do shell script "scselect AirportDisabled"
	display dialog "Airport has been turned off"
end if

Hi Stefan

Thanks for your response. The shell script as written would not work ie:

set AirportData to do shell script “/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk ‘/(Off)|(BSSID)/ {print $2}’”

However, changing it to:
set AirportData to do shell script “/system/library/privateframeworks/apple80211.framework/versions/current/resources/airport -I | awk ‘/(Off)|(BSSID)/ {print $2}’”

worked fine. I guess the difference stems from an AirPort update? This creates a problem with just how universal this script will be - different machines may be in different states of update.

Access the Internet Connect commands would be perhaps more generic?

Thanks again for your time.


Dave M

No, I try always to avoid launching applications to retrieve any data
Your changed script works also on my machine.

Alternatively you can try this:

property workNet : "myWorkNet"

	set AirportOff to (do shell script "ifconfig en1 |  awk '/status/ {print $NF}'") is "inactive"
on error
	set AirportOff to true
end try
if AirportOff then
else if (do shell script "ioreg -l | awk '/APCurrentSSID/' | cut -f 4 -d '\"'") is workNet then
	do shell script "scselect AirportDisabled"
	display dialog "Airport has been turned off"
end if