HOW-TO talk:Set up Wake-on-LAN for Ubuntu
I would like to propose a change to the final portion of the wake-on-lan script proposed to be put in /usr/local/bin/wake-on-lan. I slightly modified the script to do a pre-check to see if the system is already up and running, which makes the script usable within other scripts/commands so you're not always waiting the 10 sec to see if the target computer has come up.
Also, there should be a note included that if you don't use the hostname for the mac address, the ping just won't work.
for j, k in mmap.iteritems(): if sys.argv == j: if not re.search(X.replace('zA-Z','fA-F'), k): print "Invalid MAC address [",k,"]; nothing to do!!" sys_exit() else: c,t = commands.getstatusoutput('ping -c 2 %s' % j) if c != 0: WakeOnLan(k.translate(f1_arg,':.-')) print "WOL request has been sent to %s [%s]" % (j,k) timer('Waiting for %s wake up..... ' % j, 10) c,t = commands.getstatusoutput('ping -c 2 %s' % j) if c == 0: print "%s is up and running........\n" % j else: print "The host: %s is not running yet, try again!!\n" % j else: print "%s is up and running........\n" % j break else: print "Host [%s] doesn't exist!!" % sys.argv sys_exit()
TheGremlyn 15:04, 18 July 2012 (EDT)
- If no one voices an objection by the end of the week, I will go ahead with my proposed change.
- TheGremlyn 16:40, 8 August 2012 (EDT)
- The above has been added to the page, along with a short section on real world use. That could use more examples if anyone thinks of anything.
- TheGremlyn 16:23, 10 August 2012 (EDT)