Skip to content

Instantly share code, notes, and snippets.

@jwmickey
Created March 28, 2016 16:22
Show Gist options
  • Save jwmickey/58fa832d44500c52cc0e to your computer and use it in GitHub Desktop.
Save jwmickey/58fa832d44500c52cc0e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# simple command to wake on lan a host from a predefined list of presets.
# requires wakeonlan package to be installed
from wakeonlan import wol
import sys
if len(sys.argv) < 2:
print "Usage: %s <hostname>" % (sys.argv[0])
sys.exit(0)
hosts = {
# DEFINE YOUR HOSTS HERE, e.g:
# <hostname>: <mac-address>
}
if sys.argv[1] in hosts:
wol.send_magic_packet(hosts[sys.argv[1]])
else:
print "Unknown host: %s" % (sys.argv[1])
print "Valid hosts are: %s" % (', '.join(hosts.keys()))
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment