so, iwlist throws its output in different order depending of the wifi nic, so we need to scan and parse, to see 3 columns:
signal strength: encryption needed: ESSID
27:on:CASA
27:on:AP1133
30:on:CC5763
32:on:XX1330
36:off:gg54g
So, we wrote a script called "scan" that loops to all wlan interfaces and scans for APs.
#!/bin/bash
ifconfig -a |grep -i wlan | awk '{ print $1 }'|while read i;do
echo "#---- scanning on $i"
( ifconfig $i up
iwlist $i scan | egrep -i 'essid|freq|qual|encr' |nawk 'ORS=NR%4?" ":"\n"'| tr -s ' '| while read l;do
AP=`echo "$l "|awk '{s=substr($0,index($0,"ESSID:")+7);print substr(s,1,index(s,"\"")-1)}'`
EN=`echo "$l "|awk '{s=substr($0,index($0,"Encryption key:")+15);print substr(s,1,index(s," ")-1)}'`
QU=`echo "$l "|awk '{s=substr($0,index($0,"Quality=")+8);print substr(s,1,index(s,"/")-1)}'`
echo "$QU:$EN:$AP"
done
) | sort -n
done
View as PDF: This entry | This month | Full blog


0 Trackbacks