I can elaborate just a little bit.
When you log into a command line on a Linux/Unix/BSD type machine you are using what is called a “shell”. That is what sh, bash, ksh, zsh, fish (my favorite) etc. are all about. They provide your user interface between the terminal and the operating system. I want to say that again, it is a user interface.
A lot of the stuff that you find when using the command line is implemented by the shell. This includes anything that has to do with text redirection and kicking off programs. So pipes, >
, ;
to separate commands on one line, &&
between commands on a line to only run the second command if the first one succeeds, etc. are all features that are provided by the shell. And not all features are provided by all shells and sometimes they are different. For example the following in bash
sudo apt update && sudo apt upgrade
would be the following in fish.
sudo apt update; and sudo apt upgrade
When you are running commands from openHAB using the Exec binding or executeCommandLine, you don’t have a shell. So all of those nice features like pipes and running multiple commands on one line and such are not available to you. So the above two lines can not be run from openHAB directly.
If you need features like pipe or you need to execute more than one command, you need to put it all into a script and call the script. When you have a shell script the first line (for example #!/bin/bash
) is a directive that tells it to execute the following code in the given shell. This is what lets you use stuff like pipes in a shell script.