blob: a9f77f0c7ec9083de66d35f09e14ede6dd2996b2 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/sh
print_iwlist_env(){
# takes environment:
# count
# MAC
# CHANNEL
# QUALITY
# ENCRYPTION
# ESSID
# WPA
# WPA2
for i in ESSID MAC CHANNEL QUALITY ENCRYPTION WPA WPA2;do
eval echo ${i}_${count}=\$${i}
done
}
iwlist_scan(){
# usage: iwlist_scan $wifi-itf
ifconfig $wifi up
count=0
iwlist ${1:-} scan 2>/dev/null | ( while read line;
do
case "$line" in
*"Cell "*)
[ $count -eq 0 ] || print_iwlist_env
WPA=0
WPA2=0
: $((count+=1))
MAC="${line#*Address: }"
;;
*Channel:*)
CHANNEL="${line#*:}"
;;
*Quality=*)
QUALITY="`printf '%s' ${line#*Quality=} | cut -d/ -f 1`"
;;
*"Encryption key:"*)
ENCRYPTION="${line#*key:}"
;;
*ESSID:*)
ESSID="${line#*ESSID:}"
;;
*"IE: IEEE 802.11i/WPA2"*)
WPA2=1
;;
*"IE: WPA Version 1"*)
WPA=1
;;
*);;
esac
done; print_iwlist_env ;echo WIFI_COUNT=$count)
}
|