iwlistparse

iwlistparse Commit Details


Date:2018-05-19 15:48:05 (6 years 7 months ago)
Author:Natalie Adams
Branch:master
Commit:c6752c48ed0815cef82683ce4f3c2d70cc7bcb55
Message:initial commit

Changes:

File differences

README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
This is used to parse the output from iwlist scan
ie
iwlist wlan0 scan | python iwlistparse.py
Sample output:
7E:85:2A:A6:C0:D8 - 2.412 GHz (Channel 1) - 30/70 Signal level=-80 dBm - xfinitywifi
DC:EF:09:83:B9:E3 - 2.412 GHz (Channel 1) - 70/70 Signal level=-38 dBm - NETGEAR46
You can use the watch command to continuously run it -
watch -n 1 'iwlist wlan0 scan | python iwlistparse.py'
If you would like it to modified to be in a more consumable/queryable format (ie CSV or SQL)
please contact me
iwlistparse.py
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
62
#!/usr/bin/env python
"""
This is used to parse the output from iwlist scan
ie
iwlist wlan0 scan | python iwlistparse.py
Sample output:
7E:85:2A:A6:C0:D8 - 2.412 GHz (Channel 1) - 30/70 Signal level=-80 dBm - xfinitywifi
DC:EF:09:83:B9:E3 - 2.412 GHz (Channel 1) - 70/70 Signal level=-38 dBm - NETGEAR46
You can use the watch command to continuously run it -
watch -n 1 'iwlist wlan0 scan | python iwlistparse.py'
If you would like it to modified to be in a more consumable/queryable format (ie CSV or SQL)
please contact me
"""
__author__ = "Nathan Adams"
__copyright__ = "Copyright 2018, Nathan Adams"
__license__ = "MIT"
__version__ = "1.0"
__maintainer__ = "Nathan Adams"
__email__ = "nathan[at]allostech.com"
__status__ = "Production"
import re
import sys
def re_match_1(reString, lines):
for x in range(0, len(lines) - 1):
match = re.match(reString, lines[x])
if match:
return match.group(1)
return None
with sys.stdin as f:
address = ""
freq = ""
signal = ""
ssid = ""
lines = f.readlines()
i = 0
while lines:
# Cell 01 - Address: 7E:85:2A:A6:C0:D8
if i >= len(lines):
break
match = re.match("\s+Cell [0-9]{2} - Address: ([A-F\:0-9]+)", lines[i])
if match:
address = match.group(1)
freq = re_match_1("\s+Frequency:(.*)", lines[i:])
signal = re_match_1("\s+Quality=(.*)", lines[i:])
ssid = re_match_1("\s+ESSID:\"(.*)\"", lines[i:])
if not ssid:
ssid = "<no ssid>"
i = i + 3
#lines = lines[i:]
print "%s - %s - %s - %s" % (address, freq, signal, ssid)
else:
i = i + 1

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.05164s using 14 queries.