Detect SSID Change Python


/ Published in: Python
Save to your folder(s)

Me trying to not be a noob in python.

Yes, I know my noob is probably showing.


Copy this code and paste it in your HTML
  1. #! /usr/bin/env python
  2.  
  3. from subprocess import Popen,PIPE
  4. import re, dbus, gtk, glib, sys, os
  5.  
  6. def checkCurrentSsid():
  7. ssidpat = re.compile('ESSID:"([^"]*)"')
  8. iwconf = Popen(['iwconfig'], stdout=PIPE).communicate()[0]
  9. if ssidpat.search(iwconf):
  10. ssid = ssidpat.search(iwconf).groups()[0]
  11. print "ssid ....... " +ssid
  12.  
  13. iwpipe = os.popen('iwevent','r')
  14.  
  15. while 1:
  16. iwoutput = iwpipe.readline()
  17. if (iwoutput.find("New Access") != -1 and iwoutput.find('Not-Associated') == -1):
  18. print "iwoutput ... " +iwoutput
  19. checkCurrentSsid()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.