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.

Scheduled script only working when executed manually
#1
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
Reply
#2
Your path must be absolute, it should start with /
Code:
path = '/home/ftp/Daten/'
Reply
#3
(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!
Reply


Forum Jump: