1
I’ve researched it, and I’ve tried to make it work in many ways. execute the order:
ethers = []
ethers1 = os.system("ifconfig|grep eth|cut -c 1-4")
ethers2 = os.system("ifconfig|grep wla|cut -c 1-4")
ethers3 = os.system("ifconfig|grep ath|cut -c 1-4")
I wanted the departure of this command to be part of my empty list ethers = []
tried with the append
but it didn’t work, if you have a solution other than the os.system.
EDIT 1
Good people, I managed to solve as follows:
import subprocess, os
p = os.popen('ifconfig | grep eth | cut -c 1-4')
s = p.readline()
p.close()
print("Interface(s) Disponíveis")
print(s)
interface_internet = input(" \n Digite a Interface de Internet: ")
if interface_internet in s:
after the "if" there I will make my conditions... hope to help someone with this hugging information !
William Thank you very much for the answer, but in this case, you would have to have the empty output of the command, because it is a list of network interfaces, and you will have an "input" asked the interface that he wants to put, coincidentally I can figure out how to do, I will now edit my question and put the formula. BUT THANK YOU VERY MUCH FOR YOUR ATTENTION
– Anderson User777
well, on linux, it’s just
os.listdir('/sys/class/net/')
.– Guilherme Marthe
And then there’s the package netifaces which, along with the standard libs for networking seems to be pretty complete for this kind of problem
– Guilherme Marthe
Thanks William, I will study about what you said, obg by the tips!
– Anderson User777