我写iwconfig是为了让我的lan ESSID和mac的名字是point acess,我想恢复他的两个字段,以便在第一行的脚本中使用,但是我不能得到我想要的信息。
如何使瓦雷乌斯·埃西德和接入点
wlan0 IEEE802.11bgn ESSID:“家庭”模式:托管频率:2.437 GHz接入点: 00:03:B6:K9:L1:9E
我需要帮助。谢谢。
尝试:
proc = Popen(['iwconfig'], stdout=PIPE, stderr=DN)
print "try de iwconfig %s"%proc除了OSError:
sys.exit("Could not execute iwconfig")对于proc.communicate().split(‘\n’)中的行:打印"line %s"%line如果len(行) == 0:
continue # Isn't an empty string
if line[0] != ' ':
if 'IEEE 802.11' in line:
if "ESSID:\"" in line:
print line[ESSID][0]
if "Access Point:\"" in line:
print line[Access Point][0]发布于 2015-04-07 14:51:36
对于我的iwconfig输出,这样的正则表达式似乎运行得很好:
from re import *
from subprocess import *
proc = Popen(['iwconfig'], stdout=PIPE)
intext=str(proc.communicate()[0])
m1=search('Access Point: [ABCDEF0123456789:]*',intext)
AP=m1.group(0).split(' ')[2]
print AP
m2=search('ESSID:".*" ',intext)
ESSID=m2.group(0).split('"')[1]
print ESSIDhttps://stackoverflow.com/questions/29492336
复制相似问题