Hello, I am using OH3 and the new Action feature to call a script when a rule is executed.
The rule is:
rule "WeatherRequest"
when
Item weatherRequestItem changed
then
var String text = transform("JSONPATH", "$.status", weatherRequestItem.state.toString)
logInfo("rhasspy_intent_weather", "Message: " + text)
executeCommandLine("/etc/openhab/scripts/weather.sh", text)
end
The script is just writing the received argument to a File.
When I call the script by hand it works, but with executeCommandLine() it does not.
The Logs don’t show any error …
Im on that now for hours and really need help, thank you!
Yes I already checked permissions, I know its Linux responsibility in the end but a lot of questions/answers talk about the weird openhab permission system and I dont understand why.
As a stated in the previous comment it works now after a full restart of the system … donk ask me why I have no clue lol
I read somewhere that openhab is overwriting some permissions at start is that true?
It might explain why it works now.
Most of the confusion is between openhabian (a tool to install and configure openhab, with some popular add-ons) and openHAB (the “product”).
Openhabian does things like setting permissions commonly needed.
I’d put money on your text file being open in some other application, perhaps even a previously spawned copy of your script.
There is nothing weird about permissions with openHAB. It operates like all other Linux programs when it comes to file permissions. It doesn’t do anything different or special or unusual.
What most people have a problem with is not understanding that everything that openHAB does is as the user openhab while everything they do from a command line is done as a different user (openhabian or pi or what ever their login happens to be) and that the two users are completely separate. Or if they do understand that, they don’t understand the implications of that.
tl;dr all of those questions and answers come from people who don’t know how permissions work in Linux. And because executeCommandLine and the Exec binding are asking Linux to run a command, there isn’t really anything that openHAB can do about that.
Yes it does overwrite some file permissions sometimes, but only those files in /etc/openhab and /var/lib/openhab and only when installing and/or upgrading. It doesn’t touch any other file in any other folder, including files in /tmp. You can run openhab-cli fix-permissions or something like that also to change the ownership and permissions on the files in those folders only. And that’s because the openhab user must have permission to read/write those files to operate.
openHABian also does some file permissions stuff but, as rossko57 said, openHABian isn’t openHAB. It’s completely separate.
Ultimately we’ll never know what the problem was because you never showed us the results of the ls -l command and you never showed us the contents of the script you were trying to run. From there we might have needed additional info like other processes running and the results of commands that tell you which processes have which files open which could have proven rossko57’s theory true or false. But since you never provided any of that information