Skip to content

Instantly share code, notes, and snippets.

@initrunlevel0
Created March 24, 2014 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save initrunlevel0/9737825 to your computer and use it in GitHub Desktop.
Save initrunlevel0/9737825 to your computer and use it in GitHub Desktop.
A script to classify WLAN AP data from "iwlist scan" output
import sys
if len(sys.argv) < 2:
exit(1)
file = sys.argv[1]
cells = []
new_cell = {}
f = open(file)
for line in f.readlines():
line = line.strip()
if line.startswith("Cell"):
if(len(new_cell) > 0):
cells.append(new_cell)
new_cell = {}
new_cell['number'] = line.split()[1]
new_cell['mac'] = line.split()[4]
elif line.startswith("Channel"):
new_cell['channel'] = line.split(":")[1]
elif line.startswith("Frequency"):
new_cell['frequency'] = line.split(":")[1]
elif line.startswith("ESSID"):
new_cell['essid'] = line.split(":")[1]
elif line.startswith("Quality"):
new_cell['quality'] = (line.split("=")[1]).split(" ")[0]
new_cell['signal'] = line.split("=")[2]
for cell in cells:
print cell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment