This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

event based scripts continue to run even when they are disabled
#1
Hi,

Create virtual object.  Add the script below and run it.  Now wait until logs the first time.  Then disable the script.  It will continue to run in the background even though it should be disabled.    I would expect when you hit disabled it should kill off any running threads of the script.

thx 

Roger


Code:
mac="c0:48:e6:ee:d1:2f"

function sendWOL()
 --call the WOL
 local WOL = function(target)
   local dest_ip="255.255.255.255"
   local port=9
   local socket = require("socket")
   local udpwol = assert(socket.udp())
   udpwol:setoption('broadcast', true)
   clean_target = string.gsub(target,":","")
   clean_target = string.gsub(clean_target,"-","")
   hex_target = lmcore.hextostr(clean_target)
   payload = lmcore.hextostr("FFFFFFFFFFFF")
   for i=1,16 do
     payload = payload .. hex_target
   end
   assert(udpwol:sendto(payload, dest_ip, port))
 end
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 sleep(1)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
 WOL(mac)
end

while true do
 log("running")
 sleep(150)
 sendWOL()
 log("sent wol")
end
Reply
#2
Event scripts should never have infinite loops. You should use a resident script instead together with script.enable/disable. The only way to kill a script like this is from System config / Status / Running processes.
Reply


Forum Jump: