-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpickessid
More file actions
executable file
·58 lines (52 loc) · 1.3 KB
/
pickessid
File metadata and controls
executable file
·58 lines (52 loc) · 1.3 KB
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
#!/usr/bin/env python
import subprocess
import re
from time import sleep
#call findsignals again
#prompt for cell #
#interface with Motor
user_if = ""
essid = ""
def pickessid_init():
global user_if
global essid
user_if = raw_input("Enter the interface you want to use for scanning: ")
essid = raw_input("Enter the ESSID: ")
def get_list( wlan_if ):
proc = subprocess.Popen('sudo iwlist '+ wlan_if + ' scan 2>/dev/null', shell=True, stdout=subprocess.PIPE, )
stdout_str = proc.communicate()[0]
stdout_list=stdout_str.split('\n')
stdout_list = stdout_list[::-1]
return stdout_list
def get_signal( iwlist_list, this_essid ):
print this_essid
found = False
match = ""
for line in iwlist_list:
line = line.strip()
if not found:
match = re.search( this_essid, line )
if match:
found = True
else:
match = re.search( "Signal level=-(\d+)", line )
if match:
return match.group(1)
break
'''
while 1:
get_signal( get_list( user_if ) )
sleep(2)
essid_list=[]
signal_list=[]
for line in stdout_list:
line=line.strip()
match=re.search('ESSID:"(\S+)"',line)
if match:
essid_list.append(match.group(1))
match=re.search('Signal level=-(\S+)',line)
if match:
signal_list.append(match.group(1))
print len(essid_list)
print len(signal_list)
'''