Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2d61f831d3
Fetching contributors…

Cannot retrieve contributors at this time

executable file 31 lines (25 sloc) 0.594 kb
#!/usr/bin/env python
import os
def cmd_readlines(cmd):
fd = os.popen(cmd)
retval = fd.readlines()
return retval
darwin = False
lines = cmd_readlines("uname")
for line in lines:
if line.strip() == "Darwin":
darwin = True
# if macosx
if darwin:
lines = cmd_readlines("ifconfig en0")
for line in lines:
parts = line.split()
if parts[0] == "ether":
print parts[1]
# assume linux
lines = cmd_readlines("/sbin/ifconfig eth0")
line = lines[0]
parts = line.split()
print parts[4]
Jump to Line
Something went wrong with that request. Please try again.