So I hit a snag with a shell script that power cycled the Wi-Fi so that a preferred network setting would take effect. What I found was that I needed to figure out what the Wi-Fi interface was internally (en0, en1 etc) so I could call it correctly depending on the machine it was running on. (We have MacBook Airs where Wi-Fi is en0 and MacBook Pros where Wi-Fi is en1)
Here's the bit of code, hopefully it'll help someone else out.
wifi=`networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2`
networksetup -setairportpower $wifi off
networksetup -setairportpower $wifi on
If you've got a better way of nibbling down that -listallhardwareports output, let me know. I couldn't quite get sed to work right on this one.
I may or may not have heard that in some future version of the OS that might or might not rhyme with "Bountain Rion" that networksetup might or might not get more intelligent.