Hi, isn't Python now shipping with OSX? I haven't tested it, but wouldn't this also work while being more readable?
(DISCLAIMER: I haven't tested it. Also, I haven't tested it.)<p><pre><code> from random import randint
from os import getenv
from subprocess import call
from sys import argv
if len(argv) > 1:
# get network interface from cmdline parameter
intf = argv[1]
else:
# get network interface from ENVIRONMENT variables
intf = getenv('INTERFACE', '')
if intf:
# generate random mac address
r = lambda: randint(0,255)
randmac = '%02X:%02X:%02X:%02X:%02X:%02X' % (r(),r(),r(),r(),r(),r())
# change mac address
call(["ifconfig", "%s hw ether %s" % (intf, randmac)])
else:
print "Couldn't determine network interface"</code></pre>