Can't run a shell script via OH

This this this. We would much rather have too much information than not enough. And when you are having problems, you may not even know what is relevant or not and end with holding information we need.

Anyway, one key piece of information here

OK, so forget about messing with rules and executeCommandLines or any of that stuff.

Focus on making it work from the command line using sudo -u openhab. It’s never going to work from a rule until it works that way.

It’s not clear though what “not working” really means. Errors? If do we need to see them. Fails silently? We need to be told that explicitly too. If possible we need to find out where in that chain of calls the command is failing. Is it sshpass, ssh or the restartService.sh script on the other machine?

Sometimes ssh will not connect if the certificate on the remote machine changed for some reason. The first time you connect via ssh to a remote machine you also have to accept the certificate. Sop maybe it’s getting hung up asking for an answer that will never come.

So build up to it. To make things easy open a shell as user openhab.

sudo -u openhab /bin/bash

Now try to ssh to the remote machine

 ssh pi@Pi2_ip_address

If that worked now try it with sshpass.

If that worked now try the full command to call restartService.sh.

Only when you can get to it working from the command line running as user openhab should you mess with executeCommandLine. It won’t work there until you can make it work from the command line as the openhab user.