Bash script not executing

execbinding
executecommandline
Tags: #<Tag:0x00007f1e5c7e9970> #<Tag:0x00007f1e5c7e9790>
(Mark Lamprecht) #1

Hello,

i want to execute a bash script which push a serial command over ssh to my homebridge. When i execute the script in the terminal everything is workin fine but with the exec binding nothing happens. I also get no error message in the Log. This is my config:

rule "Blind 0"
		when 
			Item Rollo_Fenster changed 
		then
        if (Rollo_Fenster.state == ON){
            executeCommandLine("bash /home/openhabian/blinds/blind0up.sh") 
        }
        else{
            executeCommandLine("bash /home/openhabian/blinds/blind0down.sh") 
        }
end

one sample of the bash script:

#!/bin/bash
USERNAME=lampi
HOSTS="192.168.0.36"
SCRIPT="echo -e \"send 0 down\" > /dev/ttyACM0"
for HOSTNAME in ${HOSTS} ; do
    ssh -l ${USERNAME} ${HOSTNAME} -p333 "${SCRIPT}"
done

I have already set the permissions with
sudo chown openhab:openhab /home/openhabian/blinds/blind0down.sh
and sudo chmod +x /home/openhabian/blinds/blind0down.sh

Please help me

0 Likes

(Rich Koshak) #2

Please review How to solve Exec binding problems.

Also, realize that because you are not giving executeCommandLine a timeout argument, the script is executing silently in the background. As recommended in the thread I just linked to, add a timeout and log what the call to executeCommandLine returns.

If I had to guess, I’d say that OH doesn’t have permission to write to /dev/ttyAMC0.

0 Likes

(Mark Lamprecht) #3

Thanks for the help. I had no authorization for the user openhab and also the ssh key was only for user openhabian.

0 Likes