Using executeCommandLine to write output to a file from an OpenHAB rule

OpenHAB 2.5.3
Raspbian 9

I have just started using the executeCommandLine action in an OpenHAB rule. I have it working successfully in one line which grabs XML data from the National Weather Service. However, when I use a nearly identical line with the intention to write the captured XML data to a file, I get no error in the OpenHAB logs, but the file never appears, even when trying to write the file to a location to which the openhab user has permissions. I have been searching and have not found the solution yet.

This line works:

var String xmlkslc = executeCommandLine("curl -s -H accept:application/json -X GET ''", 3000) //Executes the curl string

This line does not work:

executeCommandLine("curl -s -H accept:application/json -X GET '' > /var/log/openhab2/curl-output.txt", 3000) //Executes the curl string

Any ideas?

What is the contents of your whitelist?

Making it more like the line that does work may help provide a clue

var results =executeCommandLine("curl ...", 3000) //Executes the curl string
logInfo("test", "exec return " + results)

I think that just isn’t going to work

1 Like

Thank you all for the responses! I think in this case I will just set it up as a script that will run from a cron job outside of the OpenHAB rule. I don’t need the second line to make the rule effective. I was just going to use it to save the data for comparison purposes if I need to double-check the results. If in the future, I do need to do something that requires a script to run from a rule, I will call a shell script as mentioned in the link.