Problem with script which should ssh into another computer

I’m using OpenHabian. OpenHab2 is version 2.5.12-1.
A switch triggers the execution of a script in /etc/openhab2/scripts, which should switch on/of the screen of another computer.
This is the script:

echo Schalte an >> /home/openhabian/log.log
/usr/bin/ssh root@ '/opt/vc/bin/vcgencmd display_power 1' >> /home/openhabian/log.log
echo Fertig an >> /home/openhabian/log.log

The command to execute it is

The script is executed correctly when the switch state changes. The first and the last line are working, the file /home/openhabian/log.log is written.
But the ssh command seems not to be executed. Nothing is written into the log, the screen is not getting switched on/off.
When I run the script interactively as user openhab everything works fine.
For testing I scheduled the script for user openhab via cron, works too.
But not when executed from OpenHab.
The passwordless login works fine, this should not be the problem I think.
I have no idea what to do. It would be great if somebody could point me into the right direction.

It may help to use the version of executecommandline that uses a timeout for the connection.
Fetch the returned value and use it in a log file.

returendvalue = executeCommandLine(String commandLine, int timeout)

Alternatively redirect stderr of the ssh command into your log file to see if that gives a hint.
In case that also does not help you may add switch -v or -vv or -vvv to ssh call to see what happens during the start of the ssh command.

Thanks, that helped :slight_smile:

1 Like