Preso un pezzo qua un pezzo là, adattato un pochetto.
Testato con driver ath5k
e ipw2200
Notare che driver diversi danno output un po’ diversi di iwlist
, almeno questi due.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #!/bin/bash # Usage: /bin/bash this-script.sh <wireless-iface> IFACE=$1 a=0 b=0 c=0 d=0 e=0 x=0 getWifi() { while read line; do case $line in *ESSID*) line=${line#*ESSID:} essid[$a]=${line//\"/} (( a++ )) ;; *Address*) line=${line#*Address:} address[$b]=$line (( b++ )) ;; *Frequency*) line=${line#*Channel } channel[$c]=${line//\)/} (( c++ )) ;; *Quality*) line=${line#*Quality=} quality[$d]=${line// */} (( d++ )) ;; *Encryption*) line=${line#*Encryption} encryption[$e]=${line//key:/} (( e++ )) ;; esac done < <(sudo iwlist $IFACE scan) WIFI=( "MAC Quality Channel Encryption ESSID" "----------------- ------- ------- ---------- ------------" ) while [ $x -lt ${#essid[@]} ]; do WIFI+=( "${address[$x]} ${quality[$x]} ${channel[$x]} ${encryption[$x]} ${essid[$x]}" ) (( x++ )) done } sudo ifconfig $IFACE up while true; do getWifi clear echo printf "%s\n" "${WIFI[@]}" | column -t echo unset WIFI sleep 3 done |