Only the first one is executed, I don’t know about the sleep 1 but the 2nd bus.py is definitely not executed.
I read here about similar problems and also tried to replace the spaces in the command with @@, without success.
Does anybody know how to write the items exec string to work?
ps.: I know that I can rewrite my python code or wrap a shell script around it to do the sleep or handle the functionality in an OH script, but at the moment I’m only interested in the exec binding.
This will tell you what, if any error is bing printed when this command executes. Once you get some feedback on what it is actually doing and figure out how to make it work you can move it back to the exec binding.
If I had to guess I’d say the problem is the “&&”. Keep in mind that “&&” is a shell command and it is not supported by all shells (some use “;”, some use “&”, some don’t support this concept at all). Furthermore, the openhab user is configured without a shell at all (i.e. its shell is /bin/false) so there is no shell for the openhab process to inherit when the Exec binding makes its calls. You may need to run /bin/bash -C first in order to use constructs like “&&”.
You must supply a timeout in the call to executeCommandLine as the second argument or else the call will immediately return without waiting for the command to execute. I used 5000 for five seconds in my example.
You must set the value returned by executeCommandLine to a val so it can be logged. I called it results in my example.
Finally you must log the returned value so what ever was printed by the called commands appear in openhab.log.
Change your calls to executeCommandLine to match my example above and you will see what your commands are printing.