I want to execute two commands one after another via SSH. I don't have an interactive shell. The second command should only execute if the first one succeeds, but the line is inside a script, so I'd like some user-friendly feedback if the second command fails to execute this way. After that, the rest of the script should continue executing, so
exit, etc. is not an option here.
I know I can use the boolean operator
foo && bar to prevent
bar from executing if
foo fails, and
bar || baz to execute
baz only on
bar's failure. However I am a little confused as to how these work in conjunction with each other.
To sum it up:
(Executed via SSH without an interactive shell)
foofails and prevents the execution of
ssh user@host "foo && bar || baz"
Is this a correct way to do what I just described?