On Wed, 4 Jan 2006 02:26 am, Johannes Zarl wrote: > > > I know how to use grep etc. to find known bits of output, but not > > how to isolate arbitrary output, for example ESSID names. > > > > Can anyone point me in the right direction? > > I used this in one script of mine: > > available_essids=`iwlist air0 scanning | grep "ESSID" | sed > 's/.*"\(.*\)".*/\1/'` >
[...]
Thanks to everyone who replied; it is all good advice. The above method caused
ESSIDs with spaces to become separate strings, which caused malfunctions when
the result was fed into iwconfig. In the end I used gawk with ":" as a field
separator to extract them:
networks=$(iwlist eth1 scan | grep ESSID | gawk -F: '{ print $2 }')
then using `select`, fed the result into iwconfig, which doesn't seem to mind
the quotes being preserved around the ESSID names.
I put the script into Kmenu (with "Run in terminal" and "Run as different
user" checked), and now I can quickly choose and connect to any available
wireless networks I happen to find while roaming. Just what I always wanted!
Thanks again,
John
P.s. The script is attached - it assumes your wireless interface is called
eth1.
wifind
Description: application/shellscript

