I'm facing an issue with SSH on a server. Running individual scripts (source s01.sh, etc.) works fine, with errors displayed in the console. However, when using a master script to source these scripts, the SSH connection unexpectedly terminates upon encountering an error. The master script master.sh
is as follows:
#!/bin/bash
set -e
source s01.sh
source s02.sh
Rscript s03.R
source s04.sh
I source the master script in interactive SSH session using
source master.sh
With set -e, I expect the script to stop at errors, but instead, it's causing the entire SSH session to drop. This only happens with the combined script, not with individual sourcing. Why does this occur, and how can I keep the SSH session from closing on script errors?
I am aware this might involve SSH server configurations, but I'm unsure which settings to investigate.
ssh server script.sh
or do you first open an interactive session and thenscript.sh
? or is itbash script.sh
? We need the details to be able to reproduce this.master.sh
? Looks like it would be fine to just execute the master, in which case you wouldn't have the problem.master.sh
executable but forgot about not needingsource
to execute it. Thanks for clarifying this.