Image may be NSFW.
Clik here to view.
I'm checking the replies of my previous code on Create network interfaces list using Python. E A Faisal suggestion to use
Here is my code to get the same result as my previous python code to list the network interfaces:
Seems like it is working on my ubuntu linux (in the office Image may be NSFW.
Clik here to view.
). I believe it should possibly work on other linux without any issue with that SIOCGIFCONF and ioctl. And the code is even simpler.
That's all for now... I'm going out for lunch. Happy python coding! Image may be NSFW.
Clik here to view.
Clik here to view.

I'm checking the replies of my previous code on Create network interfaces list using Python. E A Faisal suggestion to use
/proc/net/dev
is somehow seems interesting to me. Now, let's do some python code for fun before going out to lunch.Here is my code to get the same result as my previous python code to list the network interfaces:
#!/usr/bin/python
# read the file /proc/net/dev
f=open('/proc/net/dev','r')
# put the content to list
ifacelist=f.read().split('\n')
# close the file
f.close()
# remove 2 lines header
ifacelist.pop(0)
ifacelist.pop(0)
# loop to check each line
forlineinifacelist:
ifacedata=line.replace(' ','').split(':')
# check the data have 2 elements
iflen(ifacedata)==2:
# check the interface is up (Transmit/Receive data)
ifint(ifacedata[1])>0:
# print the interface
printifacedata[0]
Seems like it is working on my ubuntu linux (in the office Image may be NSFW.
Clik here to view.

That's all for now... I'm going out for lunch. Happy python coding! Image may be NSFW.
Clik here to view.
