An update to a previous post. This script has some more command line features, including a random_config_mode.
The random config mode can be used to check several AP's in the area for internet access. In internet cannot be found, the script will randomly try another connection until internet can be found again. The timer to check for internet access is randomly set between 60 to 90 seconds for an extra touch.
A preferred AP can be initially chosen in the random mode, so if it does fail, another connection will become selected. In no way is this script perfect, results may vary depending what distro you are using.
Completely run from the command line. Great for Raspberry Pi.
View it here: http://pastebin.com/vcVC9iL9