Run executeCommandLine as openhabian user

I’m trying to run a script which uses sshpass.

The rule is:
var results = executeCommandLine("/home/openhabian/ohscripts/",5000)

the script is owned by the openhab user and can be executed if I put in something like "echo something >testfile.txt

the problem is I’m trying to execute:

 sshpass -p "password" ssh root@ "ls -la"

which I can run as the openhabian user. However when putting sudo or sudo -u openhab in front of it, it does nothing. sudo -u openhab sshpass does bring up the man page.

Why do you need sudo in front of it?

Running executeCommand runs the commands as the user openhab (not openhabian). I was trying to figure out why the script was not executing, and I found out it was executing but not doing anything. So I tried to manually run the command as the openhab through the sudo command. So since I know the openhabian user can run the command wanted to specify that. I’m not sure why openhab user can’t run it.

using the rule:
var results = executeCommandLine("/home/openhabian/ohscripts/",5000)

and the script:
sshpass -p "password" ssh root@ "insert command here"

now works. Not sure why, as the only thing that has been done is: I have rebooted twice, and changed the script to use exp instead of sshpass but that would never send the password when running through openhab (fine through command line), so put back the original and now it works. I just thought I would post in case someone else has issues. It is worth trying to reboot a couple of times after install the exec binding and updating the whitelist file.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.