I wrote small script for my Raspberry Pi Project with an Adafruit 16x2 RGB LCD:
def KismetScanner():
print 'Kismet Scan'
#clearlogs = subprocess.Popen('rm -r /var/log/kismet; mkdir /var/log/kismet', shell=True, stderr=subprocess.PIPE, stdout=PIPE)
monitormode = subprocess.Popen('service ifplugd stop; ifconfig wlan0 down; iwconfig wlan0 mode monitor; ifconfig wlan0 up', shell=True)
lcd.clear()
lcd.backlight(lcd.YELLOW)
lcd.message("Enabled\nMonitor Mode")
sleep(2)
lcd.clear()
lcd.message("Scanning for\nAccessPoints 60s")
kismetscan = subprocess.Popen('kismet&', shell=True)
sleep(60)
grep1essid = subprocess.Popen('grep -oP "SSID.*>\K.*(?=<)" /var/log/kismet/Kismet-Feb-28-2015-1.xml | sed -n 1p', shell=True, stderr=subprocess.PIPE, stdout=PIPE)
grep1aOut, grep1aErr = grep1essid.communicate()
grep1bssid = subprocess.Popen('grep -oP "SSID.*>\K.*(?=<)" /var/log/kismet/Kismet-Feb-28-2015-1.xml | sed -n 2p', shell=True, stderr=subprocess.PIPE, stdout=PIPE)
grep1bOut, grep1bErr = grep1bssid.communicate()
print grep1aOut
print grep1bOut
lcd.clear()
lcd.backlight(lcd.GREEN)
lcd.message(grep1aOut + '\n' + grep1bOut)
monitormodeoff = subprocess.Popen('ifconfig wlan0 down; iwconfig wlan0 mode managed; ifconfig wlan0 up; service ifplugd start', shell=True)
sleep(2)
The script runs a Kismet Scan and extract the first found SSID and BSSID and shuould print those on the LCD. The Problem is after it should stored the SSID and BSSID in grep1aOut and grep1bOut it prints the right output, but doesn't display it on the LCD. Only the SSID, so the first line shows up, and I don't understand why.
So where is the mistake ?
Aucun commentaire:
Enregistrer un commentaire