From 9b6f31a99aaf628ed846594d48ce6761e98b57fc Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 10 Jan 2018 11:52:11 +0100 Subject: [PATCH] Redirect stderr of scp(1) to stdout to not indicate errors Some warning messages of scp(1) are written to stderr (like "Connection to ... closed by remote host."), even when there is no error and the exit code is 0 ("no error"). Therefore redirect stderr to stdout to not confuse "mail wrapper scripts" that see output on stderr otherwise. --- bin/backup-script | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/backup-script b/bin/backup-script index 89b066d..3d3db85 100755 --- a/bin/backup-script +++ b/bin/backup-script @@ -646,7 +646,11 @@ for f in "${sys[@]}"; do && cmd="$cmd ${user}@${system}:$source_root $sys_target/" \ || cmd="$cmd $source_root $sys_target/" elif [[ "$backup_type" == "scp" ]]; then - cmd="scp" + # scp writes some warning messages to stderr (like "Connection + # to ... closed by remote host."), even when there is no error + # and the exit code is 0 ("no error"); therefore we redirect + # stderr to stdout to not confuse "mail wrapper scripts" etc. + cmd="scp 2>&1" [ "$VERBOSE" -eq 0 ] && cmd="$cmd -q" for file in $files; do cmd="$cmd ${user}@${system}:$file $sys_target/" -- 2.39.2