Exec binding: script not executed

  • Platform information: Debian
    • openHAB version: 2.5.0.M1 Milestone Build

I tried to execute a little script that just creates a file (touch test)
unfortunately nothing happens.
file is executable as user openhab and is working fine if i execute on commandline

also i tried with a rule as done in the config guide of the binding. nothing

any ideas?

Thing:

Thing exec:command:ohbackup [command="/etc/openhab2/scripts/test.sh", interval=0]

Item:

Switch global_backup "Backup" (onChange) { channel="exec:command:ohbackup:run", autoupdate="false" }

Site

sitemap demo label="my map"
{
        Frame {
            Switch item=global_backup mappings=[ON="execute"] 
        }
}

Try it as an action so that you can log out the results

rule "test exec"
when
   Item global_backup received command
then
   val String result=executeCommandLine("/etc/openhab2/scripts/test.sh",5000)
   logInfo("exectest", "Command line result: {}",result)
end

I have turned on DEBUG for exec binding as well.

Result is “nothing”

22:59:29.268 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'global_backup' received command ON
22:59:29.268 [DEBUG] [untime.internal.engine.RuleEngineImpl] - Executing rule 'test exec'
22:59:29.281 [INFO ] [arthome.event.ItemStatePredictedEvent] - global_backup predicted to become ON
22:59:29.311 [INFO ] [smarthome.event.ItemStateChangedEvent] - global_backup changed from OFF to ON
22:59:29.316 [INFO ] [smarthome.event.ItemStateChangedEvent] - global_backup changed from ON to OFF
22:59:29.324 [DEBUG] [nhab.binding.exec.handler.ExecHandler] - Transformed response is ''
22:59:29.339 [INFO ] [lipse.smarthome.model.script.exectest] - Command line result:


Your script appears to run. Why don’t you have it return something, to see?

what’s inside the script?
The fact that is executable by openhab user does not necessary mean that commands inside are.

well, indeed it was the script that was facing the issue.

I was starting the backup with $OPENHAB_RUNTIME/bin/backup
after changing from PATH variable to explicit path it is working

#!/bin/bash
oh_backup() {
/usr/share/openhab2/runtime/bin/backup /root/oh_backup/OH_complete_$(date +%Y-%m-%d_%H.%M).zip
}
upload() {
/usr/bin/rclone copy ~/oh_backup/ googledrive:backup
}
oh_backup
upload
1 Like