I have a shell script that I'm working on with this line of code that does a loop through local files (.gz) and does an scp. I want to test for a failed scp
if possible. I am doing a loop so I can echo each file name to a log so I can keep track of it.
Can someone show me how to check for failed scp? or better yet, a good code example to do this? Thanks for your help.
for gzfile in $LOCALDMPDIR/*.gz
do
/usr/bin/scp -P 2222 -i $KEYFILE $gzfile foobar@$1:$TGTDIR
echo "$gzfile is done. " 2>&1
done
-q
option to scp which prevents it from prompting for a password if the key is rejected by the remote server – Petesh Jun 21 '13 at 21:36