Created
August 11, 2015 07:58
-
-
Save vincascm/7fa72a8c27933736d802 to your computer and use it in GitHub Desktop.
lua script for wake on lan(wol)
This file contains 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/lua | |
if #arg ~= 2 then | |
print("Usage: wol.lua <broadcast> <mac>\n") | |
os.exit() | |
end | |
local mac = '' | |
for w in string.gmatch(arg[2], "[0-9A-Za-z][0-9A-Za-z]") do | |
mac = mac .. string.char(tonumber(w, 16)) | |
end | |
local udp = require("socket").udp() | |
udp:settimeout(1) | |
udp:setoption("broadcast", true) | |
udp:sendto(string.char(0xff):rep(6) .. mac:rep(16) , arg[1], 9) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment