I'm running a number of scripts which often include an exit clause if the preceding commands fail, e.g.:
[ ! -d $somefile ] && exit 1;
However, I'm running this through an ssh session, and if one of these exits are executed I'm kicked out of the ssh session. Is there a way to run a script but capture any exit commands to avoid it closing the ssh connection? Changing all the scripts is not an ideal option.
sourcethose scripts, this should not be happening. ... Unless your interactive shell is running withset -e?ssh you@host some_script.sh).ssh you@host 'some_script.sh || bash -i'?