wifi script

Henk Postma henkpm at gmail.com
Wed May 3 20:24:39 UTC 2006


Hi all,

I wrote a simple script to connect to the first wifi access point it finds
and thought to share it with you.

For some reason network-admin and netapplet just are slow and/or unreliable
on my laptop ... but that can also be just me.

This script requires wireless-tools and I use it on dapper

#!/bin/bash
echo "* Turning down eth0"
ifconfig eth0 down
echo "* Turning up eth1"
ifconfig eth1 up
essid=`iwlist eth1 scanning | grep ESSID | head -n 1 | awk -F: '{print $2}'`
echo "* First ESSID found = "$essid
echo "* Connecting to it"
iwconfig eth1 essid "`iwlist eth1 scanning | grep ESSID | head -n 1 | awk
-F: '{print $2}'`"
echo "* Get an IP address"
dhclient eth1
echo "* The ESSID address is now" `iwgetid`

-- Henk Postma

--
http://www.its.caltech.edu/~postma/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060503/4d894bc5/attachment.html>


More information about the ubuntu-users mailing list