def _netstat_getnode():
 try:
  proc = _popen('netstat', '-ia')
  if (not proc):
   return
  with proc:
   words = proc.stdout.readline().rstrip().split()
   try:
    i = words.index('Address')
   except ValueError:
    return
   for line in proc.stdout:
    try:
     words = line.rstrip().split()
     word = words[i]
     if ((len(word) == 17) and (word.count(':') == 5)):
      mac = int(word.replace(':', ''), 16)
      if mac:
       return mac
    except (ValueError, IndexError):
     pass
 except OSError:
  pass

def _netstat_getnode ( ) : try : proc = _popen ( 'netstat' , '-ia' ) if ( not proc ) : return with proc : words = proc . stdout . readline ( ) . rstrip ( ) . split ( ) try : i = words . index ( 'Address' ) except ValueError : return for line in proc . stdout : try : words = line . rstrip ( ) . split ( ) word = words [ i ] if ( ( len ( word ) == 17 ) and ( word . count ( ':' ) == 5 ) ) : mac = int ( word . replace ( ':' , '' ) , 16 ) if mac : return mac except ( ValueError , IndexError ) : pass except OSError : pass
get the hardware address on unix by running netstat .