Skip to content

Instantly share code, notes, and snippets.

@lambdaterm
Created May 23, 2012 08:32
Show Gist options
  • Save lambdaterm/2773916 to your computer and use it in GitHub Desktop.
Save lambdaterm/2773916 to your computer and use it in GitHub Desktop.
test boot from NFS
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import datetime
import struct, socket, fcntl
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]])[:-1]
mac = str(getHwAddr('eth0'))
if os.path.exists("python.log." + mac):
file = open("python.log." + mac, "a")
date = str(datetime.datetime.now())
file.write(date + "\n")
else:
file = open("python.log." + mac, "w")
date = str(datetime.datetime.now())
file.write(date + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment