Script Error 512

Moderator: leecollings

Post Reply
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Script Error 512

Post by emme »

Ciao,

I'm struggling with a script that won't run....

I use to run speedtest as a device Event triggered by a virtual pushOn button...
that's the script:

Code: Select all

debugger    = tonumber(uservariables['SpeedTest_Debug'])
JSON        = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()             -- File per la decodifica del tracciato JSON restituito dallo speedtest
cTime       = os.date("*t")     
scName      = '/home/pi/domoticz/scripts/speedtest-json.sh'
runScript   = false                                                             -- Semaforo per esecuzione Procedura
prxPrint    = '>>> [ST] >>> '                                                   -- Prefisso per stringhe di debug 
idxPing     = 146
idxDl       = 147
idxUp       = 148

commandArray = {}

-- Speedtest NET_SpeedTest Button Pushed
    if devicechanged['RUNSpeedTest'] and otherdevices['RUNSpeedTest'] == 'On' then
        runScript = true
    end

-- Script Principale
    if runScript == true then
        
        print(prxPrint..'Esecuzione SpeedTest')
        
        os.execute(scName) 
    
        file = io.open("/home/pi/domoticz/scripts/speed-test.json", "r") 
        print(file)
        json_text = file:read()
        speeds = JSON:decode(json_text)
        
        print(prxPrint..'['..cTime.hour..':'..cTime.min..'] >>> Dl/Ul/Pg: '..speeds.Download_Mbit..'/'..speeds.Upload_Mbit..'/'..speeds.Ping_ms)
    
        commandArray[1]={['UpdateDevice']=tostring(idxDl)..'|0|'..speeds.Download_Mbit}
        commandArray[2]={['UpdateDevice']=tostring(idxUp)..'|0|'..speeds.Upload_Mbit}
        commandArray[3]={['UpdateDevice']=tostring(idxPing)..'|0|'..speeds.Ping_ms}
    
        os.execute("rm /home/pi/domoticz/scripts/speed-test.json")
    end

return commandArray
it works fine.... but I'm willing to move from the event table and use as an external script.
to do this I've copied the script into script_RUNSpeedTest.lua and stored in /home/pi/domoticz/script/
I've also removed the section

Code: Select all

-- Speedtest NET_SpeedTest Button Pushed
    if devicechanged['RUNSpeedTest'] and otherdevices['RUNSpeedTest'] == 'On' then
        runScript = true
    end
which is not needed anymore (the script runs ONLY when the button is pushed)
forsec runScript = true (to skip the removed block and have the rest running)

I've also added # !/usr/bin/lua on top and give the file 0777 rights (rwxrwxrwx)

trigger the OnAction on my pushbutton as: script://script_RUNSpeedTest.lua
...and got this ugly error :o :cry:
2017-02-07 11:59:55.920 Error: Error executing script command (/home/pi/domoticz/scripts/script_RUNSpeedTest.lua). returned: 512
Cannot really figured out what's wrong.... :(
did anyone saw this before and came out from it?! :P
thanks
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
SweetPants

Re: Script Error 512

Post by SweetPants »

If you run a script outside domoticz event system, you can't use CommandArray or any Domoticz specific commands
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Script Error 512

Post by emme »

That's finally clear...

Could it be an idea to explain it crealry on the Wiki also? :P
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Script Error 512

Post by jannl »

It always was clear to me from the wiki.
LUA scripts run in specified names (time/device/variable).
Running otherscripts from a switch need the full path (among other things)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Script Error 512

Post by emme »

I do not want to be controversial.. and won't get into it
jannl wrote:Running otherscripts from a switch need the full path (among other things)
This is clear in the wiki
what is not clear is that you don't have domoticz table and specific commands available
well.. you can assume it because in the event trigger section it's well explained...

Have a great day!
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest