Logic Machine Forum
Scheduled script only working when executed manually - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Scheduled script only working when executed manually (/showthread.php?tid=1383)



Scheduled script only working when executed manually - winamp - 07.05.2018

Hi all,

I want to read a json file on my HL (SV: 2.1.1) FTP server via a scheduled script every 5 minutes. But if the script is started by the cron job it gets nil for this file. If I execute the script manually or as resident script it works without a problem. Then I added a write command to the scheduled script for testing purposes and the writing worked / the script is executed. So my question is why the script can read the json file if I start it manually but not if started by the cron job?

Code:
grp.write('1/1/7', 1)

path = 'home/ftp/Daten/'
require('json')
Verbrauch_datei = 'Verbrauch.json'

Verbrauch_data = io.readfile(path..Verbrauch_datei)
log(Verbrauch_data)
if Verbrauch_data ~= nil then
    Verbrauch_data_lua = json.decode(Verbrauch_data)
else
   Verbrauch_data_lua = {}
end



RE: Scheduled script only working when executed manually - admin - 07.05.2018

Your path must be absolute, it should start with /
Code:
path = '/home/ftp/Daten/'



RE: Scheduled script only working when executed manually - winamp - 07.05.2018

(07.05.2018, 07:58)admin Wrote: Your path must be absolute, it should start with /
Code:
path = '/home/ftp/Daten/'

Now it also works with the cron job, thank you!