Hi!
I try to on/off NAT rules in Mikrotik router via ssh:
executeCommandLine('ssh xx@192.168.1.1 -p 22 ip fi nat enable numbers=' + ruleN )
error:
2021-05-03 22:16:29.720 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Error occurred when executing commandLine '[ssh xx@192.168.1.1 -p 22 ip fi nat disable numbers=1]'
java.io.IOException: Cannot run program "ssh ag@192.168.1.1 -p 22 ip fi nat disable numbers=1": error=2, There is no such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1128) ~[?:?]
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1071) ~[?:?]
Let’s assume that your path/to/my/script.sh-Script needs two item states to process them with some calculation. In console you would call it like
path/to/my/script.sh itemState1 itemState2
To solve this constellation within a rule you have to add one argument per script parameter to the function. The script above would be configured like shown below.
// When you are not interested in the script output
executeCommandLine("path/to/my/script.sh", itemState1, itemState2);
// When you need the output in your further rule processing
var ScriptResponse = executeCommandLine(Duration.ofSeconds(60), "path/to/my/script.sh", itemState1, itemState2);
// Space separated constants must be given as separate parameters as well
// e.g. path/to/your/script.sh xyz fred.file
var ScriptResponse = executeCommandLine(Duration.ofSeconds(60), "path/to/your/script.sh", "xyz", "fred.file");
If you have any ideas to make that more clear we would love to see a PR. I’d fix it but it seems very clear to me. If the script I’m calling has arguments, I need to pass each argument separately in the call to executeCommadnLine.