Solved: Magic Packet Wake on LAN Python parse error

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Solved: Magic Packet Wake on LAN Python parse error

Post by Djek » Tue May 12, 2015 8:52 am

hey all,

i try to broadcast a packet over UDP, containing the mac address of a pc, and formatted to turn a pc on.
more info about wol:
http://nl.wikipedia.org/wiki/Wake-on-LAN

btw: You need the Python lib to be properly installed;

To my surprise, the script works :D , the pc turns on, but i get an syntax error:
Unexpected EOF while parsing (line:0, offset:0)

Code: Select all

// COMPILE_OPTS|C:\projecten\DjekData\Watson\startuppc05.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
//test-magicpacket sent to pc to wake up

//stuur naar subnet 192.168.170.255 port 9

//macaddress of the pc
let>mac=54-be-f7-02-e1-d7

//convert hex to bytes
MidStr>mac,1,2,mac1
VBEval>CLng("&h" & "%mac1%"),mac1
MidStr>mac,4,2,mac2
VBEval>CLng("&h" & "%mac2%"),mac2
MidStr>mac,7,2,mac3
VBEval>CLng("&h" & "%mac3%"),mac3
MidStr>mac,10,2,mac4
VBEval>CLng("&h" & "%mac4%"),mac4
MidStr>mac,13,2,mac5
VBEval>CLng("&h" & "%mac5%"),mac5
MidStr>mac,16,2,mac6
VBEval>CLng("&h" & "%mac6%"),mac6

VBEval>chr(%mac1%),l1
VBEval>chr(%mac2%),l2
VBEval>chr(%mac3%),l3
VBEval>chr(%mac4%),l4
VBEval>chr(%mac5%),l5
VBEval>chr(%mac6%),l6

VBEval>chr(255),f

//build magic packet 
let>s1=%l1%%l2%%l3%%l4%%l5%%l6%
let>s2=%f%%f%%f%%f%%f%%f%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%

/*
python_code:

import socket

UDP_IP = "192.168.170.255"
UDP_PORT = 9
MESSAGE = "%s2%"

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
*/

LabelToVar>python_code,pcode

PYExec>pcode,u,sock

label>einde

/*Het "magic packet" bestaat uit 102 bytes.
  Het start met 6 bytes van het hexadecimale getal 255 (FF FF FF FF FF FF)
  gevolgd door zestien keer het 48-bit MAC addres van de computer die opgestart dient te worden.
*/

I m lost, perhaps because im staring at it i do not see the problem..... :?

/////////////////////////////BREAKING NEWS !!///////////////////////////////
Solved,
i forgot to put in sock in the syntax:
PYExec>pcode,u,sock
i ve fixed it in the script above
/////////////////////////////BREAKING NEWS !!///////////////////////////////

Thanks in advance,
kind regards,
Djek

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Re: Solved: Magic Packet Wake on LAN Python parse error

Post by Djek » Thu May 14, 2015 8:07 am

hi
for anyone who likes to use the straightened version:

Code: Select all


//macaddress of the pc
let>mac=54-be-f7-02-e1-d7
//broadcast mask
let>brdcst=192.168.170.255

//convert hex to bytes
let>t=-2
let>tt=0
label>leeswaarde

  let>t=t+3
  let>tt=tt+1
  MidStr>mac,%t%,2,macuit
  VBEval>CLng("&h" & "%macuit%"),macchar
  VBEval>chr(%macchar%),luit
  let>l%tt%=luit
  if>t<16
    goto>leeswaarde
  endif
  VBEval>chr(255),f

//build magic packet
  let>s1=%l1%%l2%%l3%%l4%%l5%%l6%
  let>s2=%f%%f%%f%%f%%f%%f%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%%s1%

/*
python_code:
import socket
UDP_IP = "%brdcst%"
UDP_PORT = 9
MESSAGE = "%s2%"
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
*/

  LabelToVar>python_code,pcode
  PYExec>pcode,u,sock



kind regards,
Djek

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts