Created
March 28, 2020 04:55
-
-
Save sdgandhi/5b5d4232da209b89134b97a27bdd371f to your computer and use it in GitHub Desktop.
wake on lan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import sys | |
if len(sys.argv) < 3: | |
print "Usage: wakeonlan.py <ADR> <MAC> (example: 192.168.1.255 00:11:22:33:44:55)" | |
sys.exit(1) | |
mac = sys.argv[2] | |
data = ''.join(['FF' * 6, mac.replace(':', '') * 16]) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
sock.sendto(data.decode("hex"), (sys.argv[1], 9)) | |
# python wake.py 192.168.1.255 00:11:22:33:44:55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment