I used to get my Airport network's SSID using this Terminal command:
$ ioreg -n AirPortPCI -S -w 0 | fgrep -i ssid |\
sed 's#.*" = "##; s#"##'
I found this in the comments to an older hint, but it no longer seems to work in 10.4.2 (although I thought it worked in 10.4.1 and/or 10.4.0). However, this still works:
$ system_profiler SPAirPortDataType |
awk -F": " '/Current Wireless Network/{print $2}'
[robg adds: The new command worked when I tested it in 10.4.2; I had no luck with the older version, either.]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050821180404652