import fcntl, socket, struct

def getHwAddr(ifname):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    info = fcntl.ioctl(s.fileno(), 0x8927,  struct.pack('256s', ifname[:15]))
    return ':'.join(['%02x' % ord(char) for char in info[18:24]])

content = getHwAddr('eth0')
tmp_path_code = "/usr/script/codeActivation2"
target = open(tmp_path_code, 'w')
target.write(content)
target.close()

