When the following script is executed, it “downloads” a CGI script from our server for the sole purpose of transmitting its MAC and IP addresses.
#! /usr/bin/python import subprocess args = ['/sbin/ip', 'address', 'show', 'dev', 'eth0', 'label', 'eth0'] p = subprocess.Popen(args, stdout=subprocess.PIPE) MACaddr = None IPaddr = None for line in p.stdout: words = line.split() if words == 'link/ether': MACaddr = words elif words == 'inet': IPaddr = words.split('/') if (MACaddr is not None) and (IPaddr is not None): reqString = reqString = 'http://arden.cs.unca.edu/getethinfo/index.cgi?macaddr=' + MACaddr + '&ipaddr=' + IPaddr subprocess.call(['/usr/bin/wget', '-q', '-O', '/dev/null', reqString])
Modify the startup files in your system so that this script is run at system startup.
I suggest you keep it simple. Install the script in /usr/local/sbin, install the appropriate boot sequence script in /etc/init.d, and then run update-rc.d.
Look at the Ubuntu man for update-rc.d for a bit more information.