Bash script to toggle wifi in lion Is it possible to have a bash script that toggle my wifi on and off? I am using lion (10.7.2).
Assuming your hardware is somewhat similar to mine:

networksetup -setairportpower en1 on
networksetup -setairportpower en1 off


You can run networksetup -listallhardwareports to find the device (en1) of your Wi-Fi in case it's different.

To toggle put something like the following lines into a script or shell function:

[[ "$(networksetup -getairportpower en1)" == *On ]] &amp;&amp; v=off || v=on
networksetup -setairportpower en1 $v