Issue with exec commend but through terminal it work

Hello!
My system:
OH3 openhabian 3.1.0 on pi4

I try to do according to this guide:
Automate backups and upload them to Google Drive - Tutorials & Examples - openHAB Community

And I encounter the following error:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'backup-1' failed: An error occurred during the script execution: array element type mismatch in backup

If I run through the terminal ./backup.sh then the script works great.

  • In the script and in the rule I changed the patch from openhab2 to the correct location
  • In exec.whitelist I entered
    /etc/openhab/scripts/backup.sh
  • In /etc/sudoers I inserted
Cmnd_Alias BACKUP = /usr/bin/ openhab-cli backup, /usr/bin/rclone
openhabian ALL = (ALL) NOPASSWD: BACKUP

what could be the problem?

How does your executeCommandLine entry in your rule look like ? The thread you are referring to uses OH2 syntax which is not compliant to OH3 syntax.

like this:

var String BackupCliOutput = executeCommandLine("/etc/openhab/scripts/backup.sh", 120*1000)

Syntax in OH3 is:

var String BackupCliOutput = executeCommandLine(Duration.ofSeconds(120*1000), "/etc/openhab/scripts/backup.sh");

thanks, now i get new massage of error, do you have any idea what it is:?

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified

That’s an initial message that user openhab needs to accept to continue to run sudo commands.
Have a look at OpenHAB sudo [Exec Binding] for explanation.
You need to run

sudo -u openhab sudo -l

once. After that the sudo command should work.

Thanks for you helps!

1 Like