I wanted to update this with my results in case anyone else wants to do something similar. This is not complete yet, but it is somewhat functional with known AP's. I currently have to reboot when I change AP's because iwconfig is not automatically releasing the previously-found connection, but I hope to fix that in time. Also be aware that you will of course not be able to use the GUI to configure your wireless network connection after making these changes.
OK on to the good stuff. The first file to modify is /etc/network/interface. You will need to comment out or remove the section that defines wlan0. Replace it with code similar to this:
mapping wlan0
script /etc/network/findwifi.sh
map home,*,*,00:11:22:33:44:55 home
map work,*,*,AA:BB:CC:DD:EE:FF work
map any,*,*,* any
iface home inet dhcp
wireless_mode managed
wireless_essid home_ssid
wireless_key off
wireless_channel 11
iface work inet dhcp
wireless_mode managed
wireless_essid work
wireless_key open key 0000-0000-0000-0000-0000-0000-00 [1] key [1]
wireless_channel 6
iface any inet dhcp
wireless_essid any
wireless_mode managed
Note that on the 'map' lines you will want to put in the MAC address of your AP's. You can find this from the command line with iwconfig. If you do not have a connection to your AP, type in "iwconfig wlan0 essid your_ssid_here". Once you have a current connection to your AP, type "iwconfig wlan0", and look for the line with the text "Access Point:". The text after this is your MAC address.
The next step is to create the script findwifi.sh. This should be placed in /etc/network/.
#!/bin/sh
iface="$1"
ifconfig $iface up
cat /etc/network/interfaces | grep "map " | while read x INFO NAME
do
SSID=`echo $INFO | cut -d, -f1`
if [ "$SSID" = "*" ]; then SSID=any; fi
MAC=`echo $INFO | cut -d, -f4`
iwconfig $iface essid $SSID 2>/dev/null
sleep 1
NEWMAC=`iwconfig wlan0 2>/dev/null | grep "Access Point" | sed -n -e 's/.*Point: /\1/p'`
if [ $NEWMAC = $MAC ]; then
echo $NAME
exit 0
fi
done
Remember to chmod 755 then file after you create it. This script tries out each SSID identified in the interfaces file, in order, and returns the name of the first match. If you want to manually run this file, include the interface name on the command line like such: ./findwifi.sh wlan0
I still need to get the script to drop the old ssid so it can cleanly search for a new AP whenever you insert your wifi card. Also I want to use "iwfind wlan0 scanning" to attempt to locate an open wifi if one of the primary defined AP's are not detected. And finally, I would like to find a way to re-run this script any time the connection is lost so that wireless connectivity can be seamlessly maintained when roaming. (If anyone has suggestions on detecting when wifi is lost, let me know?)