Launch only the command if the previous one worked inside SSH, SHELL

Posted by Namari on Super User See other posts from Super User or by Namari
Published on 2012-10-11T22:54:47Z Indexed on 2012/10/12 3:39 UTC
Read the original article Hit count: 445

Filed under:
|
|

I've got a SHELL script which is using a pipe to separate my 2 commands:

ssh -oBatchMode=yes user@hostname "mysql -u yop -pyop -c yop | echo test"

The problem is even if my connection to mysql doesn't work, it send the echo test. I would like to forbid my script to send any command if the previous command doesn't work.

I search with a if condition but it seems it not possible with it :(

Does anyone have an idea ?

Thanks,

Namari

© Super User or respective owner

Related posts about shell

Related posts about ssh