quick command line wpa with wpa_supplicant. Some older devices (like my iBook) are not real supported using gui WPA connection methods. But I can usually get the command line going.

install wpa_supplicant based on the preferred method of your distribution. Note, below you will need to substitute eth1 with your interface device. It could be eth0 or wlan0 or whatever.

nano /bin/location1.sc

paste in the following

rm /var/run/wpa_supplicant/eth1
wpa_supplicant -ieth1 -Dwext -clocation1.conf &
sleep 5
dhclient eth1

back in terminal

chmod + x /bin/location1.sc
nano /bin/location1.conf

paste in the following
ap_scan=1
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="MYESSID"
scan_ssid=0
proto=WPA
key_mgmt=WPA-PSK
psk="MYPASSKEY"
pairwise=TKIP
group=TKIP
}

Now when you want to connect to this location you open a terminal, and as root type ‘location1.sc’. You can create as many locations as you want. I have a location home.sc with its home.conf and a work.sc with its work.conf.

Advanced Fun
Create 2 locations by following the instructions above. You can make the computer find the location and automatically connect using the following little script.
As root
nano /bin/on.sc
Paste in the following
ifconfig eth1 down
ifconfig eth1 up
iwlist scanning | grep MyESSID1 && /bin/location1.sc
iwlist scanning | grep MyESSID2 && /bin/location2.sc
/bin/mnt.sc

Then back at a prompt, as root
on.sc

The script will scan for your network, locations and finding the ESSID it will go ahead and execute your other script and jump on it. If it doesn’t find location1, it will try location2 (and more if you add them). Notice that last line /bin/mnt.sc? Well that is the next fun part.

More fun
This script attempts to connect to a samba server, but only if that server is ping’able on the network.
nano /bin/mnt.sc
paste in the following

Pinged1()
{
Successfully Pinged1!!!
mkdir /mnt/share
mount -t cifs //{servername}/share /mnt/share -o user=winuser,pass=winpass
ls /mnt/share
}
ping -c 1 {servername} && Pinged1
But substitute your samba server’s name (or IP) and share name as well as winpass and winname. You could connect to multiple servers by repeating this section multiple times, incrementing the Pinged1 (in both locations) to Pinged2 etc.You could include all of the servers on your network(s) so one script scans for available networks, connects to them, and then mounts your shares for you.

I love automation