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', bytes(ifname, 'utf-8')[:15]))
    return ':'.join('%02x' % b for b in info[18:24])

content = getHwAddr('eth0')
tmp_path_code = "/usr/script/codeActivation2"
target = open(tmp_path_code, 'w')
target.write(content)
target.close()

