Skip to content

Instantly share code, notes, and snippets.

@Tiggar
Created July 18, 2009 08:34
Show Gist options
  • Save Tiggar/149478 to your computer and use it in GitHub Desktop.
Save Tiggar/149478 to your computer and use it in GitHub Desktop.
(*
Script adapted from Wake on WAN - by Mark Muir (2008-04-01)
http://forums.dealmac.com/read.php?4,2751523
*)
property MAC_address : "00:25:4b:9f:63:c8"
property WAN_IP_address : "255.255.255.255"
on run
set command to "/usr/bin/php -r " & quoted form of ("$mac = " & quoted form of MAC_address & "; $ip = " & quoted form of WAN_IP_address & "; " & "
$mac_bytes = explode(\":\", $mac);
$mac_addr = \"\";
for ($i=0; $i<6; $i++)
$mac_addr .= chr(hexdec($mac_bytes[$i]));
$packet = \"\";
for ($i=0; $i<6; $i++) /*6x 0xFF*/
$packet .= chr(255);
for ($i=0; $i<16; $i++) /*16x MAC address*/
$packet .= $mac_addr;
$port = 9;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);
socket_close($sock);
")
do shell script command
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment