Not without execute permissions, it doesn’t. I guarantee /etc/openhab/scripts/resetmodbus.sh does not work from an ssh session due to no execute permissions.
sh /etc/openhab/scripts/resetmodbus.sh wiould work, bypassing the permissions issue so that is not a valid test.
Right now this is a Linux issue, not an openHAB one.
2020-12-07 00:58:04.036 [WARN ] [shd.server.session.ServerSessionImpl] - exceptionCaught(ServerSessionImpl[null@/127.0.0.1:46000])[state=Opened] IOException: Połączenie zerwane przez drugą stronę
I need to add logentry to this rule to check what is going on.
yes it is:
[shd.server.session.ServerSessionImpl] - exceptionCaught(ServerSessionImpl[null@/127.0.0.1:40886])[state=Opened] IOException: Connection reset by peer
I add chmod, changed chown to openhab:openhabian and still same result.
/bin/date >> /tmp/test.txt
/bin/echo "this line was executed" >> /tmp/test.txt
after the line with the shebang in the script file.
In case you see the result of the call to date and echo in /tmp/test.txt file we see that the shell script starts to execute. In case this is not visible in the test.txt file the shell script is not executed.
Or have you already done a similar test ?
Not sure if OH3 checks the ownershop of the script that is to be executed. Your script is owned by user openhabian and not by user openhab. I understand that you added x permission for u, g, o. In case OH3 checks the ownership it might be the case that the execution is not allowed if it is owned by an other user.
EDIT: just saw that you had the same idea and I just was typing too slow
Files to be executed must be readable and executable for user openhab.
For output to be stored the directory / file needs to be writeable for user openhab.
That’s what I thought.
But I have this
-rwxrwxr-x 1 openhab openhabian 181 Jan 12 09:03 opnsense.sh
and it’s not working.
this is what I call:
executeCommandLine(Duration.ofSeconds(10), “sudo /etc/openhab/scripts/opnsense.sh”)
Everything was working correctly before the update to OH3.
works. Pay attention to the double quotes in case you copy code from the forum to your rule. It could be that instead of the ASCII double quotes a set of utf-8 double quotes are used.
Is the openhab user member of the sudo group on your system?
I think that is not the case for the defualt installation.
Permissions that are shown are ok.
Shebang ( #! ) in the script defines the interpreter to be used ?
Does the script just execute an action or do you also expect to get output back from the script ( may be into a variable in OH ) ?