简体   繁体   中英

How to find the mode (Monitor or Managed) of a wireless interface (ex. wlan0) using Python

No idea where to even start here. Any ideas? I'd like to do this only using python if possible. Could not find any other threads that answered this in the slightest.

Python generally doesn't really have access to low-level hardware devices. You might find 3rd party package that can get you what you want, but you're probably better off capturing the output of a command line utility via subprocess and parsing the output.

This example output of iwconfig would be pretty straightforward to parse:

wlan0     IEEE 802.11g  ESSID:"NETGEAR"  
          Mode:Managed  Frequency:2.462 GHz  Access Point: 00:0F:B5:CE:E3:2A   
          Tx-Power=27 dBm   
          Retry min limit:7   RTS thr:off   Fragment thr=2346 B   
          Encryption key:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Note: the output format/content will likely vary based on your adapter and driver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM