Networking

H.J.Bathoorn triade-lists at zeelandnet.nl
Thu Apr 5 23:03:36 UTC 2007


On Thu, 5 Apr 2007 23:53:51 +0200
H.J.Bathoorn wrote:

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

On rereading my own mail I saw some stuff that wasn't needed, here's the shorter script:
I left out most off the comments as well, this time.
-------------------------------------------------------------------------------------------
#!/bin/bash
## A script to easily (oh well, tastes differ) find and connect to wifi AP's

unset var1
unset var2
rm -f /tmp/ssid.txt
rm -f /tmp/essid.txt
cardctl eject
sleep 1
cardctl insert
sleep 1

## get rid of restrictive already 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
iwlist ra0 scanning |egrep -i -n -A 1 essid|cut -d"-" -f2 > /tmp/ssid.txt
## Ask the number of the wanted AP
echo -n "which one to try? Please enter number:" ;echo ; read "var1"

declare var2= `cat /tmp/ssid.txt |grep $var1 |cut -d"\"" -f2 |sed 's/"//g'`
##Give some feedback
echo "Setting $var2 as essid and connecting!..."

##so let's connect:-)
iwconfig ra0 essid $var2 &&
echo
dhclient ra0 &&
echo
echo "Success, have fun ;-)"
## And get enough time to read succes ;-)
sleep 4
exit 0
-------------------------------------------------------------------------------------------------------
pointers for more honing would be appreciated.
-- 

Good luck,
HarM.




More information about the kubuntu-users mailing list