Reputation: 674
I'm accessing ifconfig, iwconfig and iw from subprocess.Popen as below:
p = sp.Popen(["ifconfig",nic],stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.PIPE)
out,err = p.communicate()
Is there a better way, i.e faster to do this such as interfacing directly to the underlying code perhaps or is the added time delay negligible - time becomes a concern when using iw to switch channels.
Upvotes: 0
Views: 2290
Reputation: 674
So, finally got around to writing own code - interfaces directly with netlink and ioctl to handle iw and ifconfig respectively - hosted on https://github.com/wraith-wireless/pyric and https://pypi.python.org/pypi/PyRIC/
Upvotes: 1
Reputation: 43505
Try reading/writing the relevant files from the /proc
filesystem directly.
The /proc
pseudo filesystem is where the Linux kernel exposes a lot of information. You might want to look around in /proc/net
, especially /proc/net/dev
and /proc/net/wireless
. See the documentation, and some more information.
Upvotes: 2