airport script has preferences.plist.old error

A workaround for macs to connect to my college’s network is simply to turn off and back on airport. In 10.5 i was able to run this script with great and fast success:

do shell script "/usr/sbin/networksetup -setairportpower off"
do shell script "/usr/sbin/networksetup -setairportpower on"

Now, in 10.6, i receive this error:

“cp: /Library/Preferences/SystemConfiguration/preferences.plist.old: Permission denied”

I’ve tried to change permissions for that file, but Terminal tells me that no such file exists. Anyone know how I can fix this? Thanks!

Hi,

I guess you must run networksetup as root (in AppleScript with administrator privileges)

Good idea. I tried that and got a HUGE list of “errors” which seemed to be a list of all possible networksetup shell scripts. One of them was this:

networksetup -setairportpower

I tried again with “airport” as the device name and it worked. Then again without the administrative privileges, which also works (without a password prompt).

Weird. This is what works:

do shell script "/usr/sbin/networksetup -setairportpower airport off"
do shell script "/usr/sbin/networksetup -setairportpower airport on"

Thanks for the tip!