I’ve created a rule, and the command.sh script, after adding the shebang and +x permission the command is correctly executed.
Now I’m wondering how to add the results as loginfo.
rule:
var String results = ""
executeCommandLine("/home/openhabian/workspace/command.sh")
logInfo("Titolo","testo" + results)
command.sh:
#!/bin/bash
echo "ciao" >> /tmp/ciao
log:
==> /var/log/openhab/openhab.log <==
2021-12-13 10:22:28.701 [INFO ] [org.openhab.core.model.script.Titolo] - testo
2021-12-13 10:22:28.702 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'fde860b80a' is executed.
If I replace this row in rule, it goes to error:
results=executeCommandLine("/home/openhabian/workspace/command.sh")
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'fde860b80a' failed:
var String results = ""
results=executeCommandLine("/home/op ___ enhabian/workspace/command.sh")
logInfo("Titolo","testo" + results)
Type mismatch: cannot convert from void to String; line 4, column 36, length 57
javax.script.ScriptException:
var String results = ""