Hi guys,
I used a slightly modified version of the turn airport off script from the resource kit to.. erm.. turn off the airport.
It looks like apple have "fixed" 10.7, so instead of issuing:
/usr/bin/networksetup -setairportpower *HardwarePortName* off
You now need to do the following:
/usr/bin/networksetup -setairportpower *DeviceName* off
*DeviceName* is listed when you run,
/usr/sbin/networksetup -listallhardwareports
So i tried:
/usr/sbin/networksetup -listallhardwareports | awk '/^Hardware Port: "$checkWireless"/,/^Ethernet Address/' | head -2 | tail -1 | cut -c 9-
where checkWireless is set using the following:
checkWireless=$(networksetup -listallhardwareports | egrep "Hardware Port: (Air|Wi-)" | cut -c 16-)
But the variable does not seem to be passing. script below.. maybe there is a better way?
In context below:
if [[ "$OS" == "10.4" ]]; then
# If OS is 10.4.x run the following to turn off Wireless...
echo "Turning off the Wireless for OS $OS..."
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -setairportpower off
exit 0
elif [[ "$OS" == "10.5" ]]; then
# If OS is 10.5.x run the following to turn off Wireless...
echo "Turning off the Wireless for OS $OS..."
/usr/sbin/networksetup -setairportpower off
exit 0
elif [[ "$OS" == "10.6" ]]; then
# If OS is 10.6.x run the following to turn off Wireless...
echo "Turning off the Wireless for OS $OS..."
/usr/sbin/networksetup -setairportpower "$checkWireless" off
exit 0
elif [[ "$OS" == "10.7" ]]; then
# If OS is 10.7.x run the following to turn off Wireless...
checkWireless=$(networksetup -listallhardwareports | egrep "Hardware Port: (Air|Wi-)" | cut -c 16-)
# First we need to get the Wi-Fi device's name
wifiDevice=/usr/sbin/networksetup -listallhardwareports | awk '/^Hardware Port: "$checkWireless"/,/^Ethernet Address/' | head -2 | tail -1 | cut -c 9-
echo "Wi-fI Turning off the Wireless for OS $OS..."
/usr/sbin/networksetup -setairportpower "$wifiDevice" off
exit 0
fi