H.J.Bathoorn triade-lists at
Thu Apr 5 21:53:51 UTC 2007

On Thu, 5 Apr 2007 16:28:13 -0500
Howard wrote:

> Now, if you are using the same nic to connect to different locations there are 
> better ways, and if anyone has those figured out I'd like to know as well.  
> Because network manager just doesn't work.  

I don't know if this is "a better way" but works for me when traveling and quickly searching for hot spots (I'm a Fonera) and/or available open networks.
It's on my panel (but an icon on the desktop does the same) which launches: kdesu "xterm ~/wifi-script" .
here's my wifi-script:
## A script to easily (oh well, tastes differ) find and connect to wifi AP's

## First get rid of variables unexpectedly left over from prior runs
unset var1
unset var2

## same goes for the txt files
rm -f /tmp/ssid.txt
rm -f /tmp/essid.txt

## re-initialize the card just to be sure. Mine's a ralink PCMCIA card
cardctl eject
sleep 1
cardctl insert
sleep 1

## get rid of retrictive allready joined network for iwlist to work properly
## change ra0 to whatever your card is called, like "wlan0" or "eth1"
iwconfig ra0 essid " " &&

## show all AP's and their encryption state preceded by a line number and write to /tmp/ssid.txt
#iwlist ra0 scanning |grep -i essid |nl > /tmp/ssid.txt    # this is the old command
##this is a better line though still not perfect:
iwlist ra0 scanning |egrep -i -n -A 1 essid > /tmp/ssid.txt 

##remove the -- that grep puts in there as well as the line numbers for encryption
cat /tmp/ssid.txt |cut -d"-" -f2

## Ask the number of the wanted AP
echo -n "which one to try? Please enter number:" ;echo ; read "var1"

##remove all the cruft and write choice to /tmp/essid.txt (delimiter=") 
cat /tmp/ssid.txt |grep $var1 |cut -d"\"" -f2 > /tmp/essid.txt

##declare the variabel and get rid of the quotes in there with sed. Mind the bactick!
declare var2=`cat /tmp/essid.txt|sed 's/"//g'`

##Give some feedback
echo "Setting $var2 as essid and connecting!"

##so let's connect:-)
iwconfig ra0 essid $var2 &&

##and get a DHCP offer from the router
dhclient ra0 &&
echo "Success, have fun ;-)"

##get rid of the /tmp/files -- not really needed!
rm -f /tmp/*id.txt
## And get enough time to read succes ;-)
sleep 4

##Quit the terminal
exit 0


There's definitely some stuff that could be done better or cleaner, but it works for me. :-) 


Good luck,

More information about the kubuntu-users mailing list