summaryrefslogtreecommitdiffstats
path: root/usr/bin/iwlist_env
blob: 29112ff3fe3443e8f33fc251a5efde75fe153c18 (plain)
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
#!/bin/sh

count=0

iwlist scan ${1:-} 2>/dev/null | ( while read line;
do
    case "$line" in
        *"Cell "*)
            #echo
            : $((count+=1))
            echo MAC_${count}="${line#*Address: }"
            ;;
        *Channel:*)
            echo CHANNEL_${count}="${line#*:}"
            ;;
        *Quality=*)
            echo QUALITY_${count}="`printf '%s' ${line#*Quality=} | cut -d/  -f 1`"
            ;;
        *"Encryption key:"*)
            echo ENCRYPTION_${count}="${line#*key:}"
            ;;
        *ESSID:*)
            echo ESSID_${count}="${line#*ESSID:}"
            ;;
        *"IE: IEEE 802.11i/WPA2"*)
            echo WPA2_${count}=1
            ;;
        *"IE: WPA Version 1"*)
            echo WPA_${count}=1
            ;;
        *);;
    esac
done; echo WIFI_COUNT=$count)