import commands

ETHER_NAME=0
HEADER=2

result=commands.getoutput('netstat -ni').split('\n')[HEADER:]
ether_name=[]
for line in result:
    ether=line.split()[ETHER_NAME]
    if ether != 'lo':
        ether_name.append(ether)
print ether_name


['eth0', 'eth1']

+ Recent posts