-
-
Save stevehodgkiss/2425073 to your computer and use it in GitHub Desktop.
Command to send wake on lan packets
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/env ruby | |
@mac = "xx:xx:xx:xx:xx:xx" | |
@address = "myaccount.dyndns.org" | |
@port = "9" | |
@count = 3 | |
require 'socket' | |
@socket = UDPSocket.open | |
@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1) | |
magicpacket = (0xff.chr)*6+(@mac.split(/:/).pack("H*H*H*H*H*H*"))*16 | |
@count.times do | |
@socket.send(magicpacket, 0, @address, @port) | |
sleep 1 | |
end | |
puts @count == 1 ? "Sending magic packet to #{@address}:#{@port} with #{@mac}" : "Sending magic packet to #{@address}:#{@port} with #{@mac} #{@count} times" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment