"PING" an AP to see if it's alive? (Before associate with it)

view story

http://unix.stackexchange.com – I would like to detect if a certain AP address is avlive, i.e by "PING" its SSID or MAC address (both known), What program can I use to archive that? I'm making a simple script that run as root. (I hope I wouldn't be doing this by something like iwlist scan | grep XX) (HowTos)