Skip to content

Instantly share code, notes, and snippets.

@vincascm
Created August 11, 2015 07:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincascm/7fa72a8c27933736d802 to your computer and use it in GitHub Desktop.
Save vincascm/7fa72a8c27933736d802 to your computer and use it in GitHub Desktop.
lua script for wake on lan(wol)
#!/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