>> import py_compile

>> py_compile.compile('test.py')

>> quit

너무 간단한가요??

import socket

socket.gethostbyname(socket.getfqdn())

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