Skip to content

Commit f1f15ab

Browse files
author
freddii
committed
added wifi-list.sh
1 parent 5ed3668 commit f1f15ab

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

wifi-list.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
if [ $# -lt 1 ]; then
4+
echo "usage: $(basename $0) INTERFACE" >&2
5+
exit 1
6+
fi
7+
8+
iwlist "$1" scan | awk '
9+
BEGIN {
10+
c[0] = "C"; a[0] = "Address";
11+
q[0] = "Q"; s[0] = "ESSID";
12+
l[0] = "L"; e[0] = -1;
13+
k[-1] = "Enc"; k[0] = "None"; k[1] = "WEP";
14+
k[3] = "WPA"; k[5] = "WPA2"; k[7] = "WPA+WPA2";
15+
}
16+
$1 == "Cell" {
17+
a[++n] = $5;
18+
}
19+
$1 ~ "^Channel:" {
20+
split($1, t, ":");
21+
c[n] = t[2];
22+
}
23+
$1 ~ "^Quality=" {
24+
split($1, t, "=");
25+
q[n] = t[2];
26+
split($3, t, "=");
27+
l[n] = t[2];
28+
}
29+
$1 ~ "^ESSID:" {
30+
split($0, t, "\"");
31+
s[n] = t[2]
32+
}
33+
$0 ~ "Encryption key:on" {
34+
e[n] = 1;
35+
}
36+
$0 ~ "IE: WPA" {
37+
e[n] += 2;
38+
}
39+
$0 ~ "IEEE 802.11i/WPA2" {
40+
e[n] += 4;
41+
}
42+
END {
43+
if (n > 0) {
44+
for (i = 0; i <= n; i++) {
45+
printf("%-17s %2s %5s %3s %-8s %s\n",
46+
a[i], c[i], q[i], l[i], k[int(e[i])], s[i]);
47+
}
48+
}
49+
}'
50+

0 commit comments

Comments
 (0)