Created
July 4, 2021 16:29
-
-
Save sureshjoshi/aa47609ace3e6227c69ca335b2155e4e 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 = bytes.fromhex("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, (sys.argv[1], 9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment