I have a shell script with below ssh command to perform few actions,
$SSH $user@$remoteIpAddress "sudo rm -rf $remoteLocation/xxx/*; cd $remoteLocation/yyy; .... ... "
Directory $remoteLocation/yyy is not available and it will display the error as,
./test.sh: line 6: cd: /opt/test/yyy: No such file or directory
and it is proceeding to the next line. My scenario is to exit from the shell script itself if any command in ssh returns non-zero value. I could add set -e to exit from shell but i am not sure how to handle it in ssh. Thanks in advance.
EDIT :
I have few lines of command below the SSH command. I need a solution to exit entirely from the script and not to execute any lines below the ssh command.