Exec binding PaperUI Thing with Parameter

Im trying to run a script and pass a parameter to it

But getting this in log:

An exception occurred while executing "/etc/openhab2/scripts/sma.script TotalPac" : 'Cannot run program ""/etc/openhab2/scripts/sma.script": error=2, No such file or directory'

The file is there and I can run it from the command line, it is permission 777 to overkill it

Anyone any idea?

1 Like

You cannot pass parameters to scripts
Therefore your system cannot resolve that command and returns not found

ok thanks - we trying to do the same in paperUI as this guy was and seemed to be able to in a thing file

I think you are mixing up the term script.

Unfortunately in OH Script has a very specific meaning. A Script is a piece of Rules DSL code that you can call from a Rules DSL Rule. Vincent is correct, you cannot pass parameters to a Rules DSL script.

But you appear to be trying to execute a script (I use capitalization to distinguish between generic terms like things and items and OH specific terms like Things and Items) using the Exec binding. This is something completely different. First of all, these scripts are not Rules DSL code. They are shell scripts or python scripts or perl scripts or the like. You CAN pass command line arguments to these scripts. If you add %2$s to the end of your Command, then what ever state that the Item linked to the Input Channel will be passed to the script as an argument.

So a final couple of things to say about scripts. First, these should NOT be placed in the conf/scripts folder. That folder is intended to store Scripts. If you use the full path to execute it then it doesn’t really matter where you put it but in the past putting it in that scripts folder caused problems (probably not a problem any more). Second, you should use an appropriate extension for the script. Based on the thread you linked to this is a shell script so it should be named sma.sh.