SSH Remote command exit code
问题 I know there are lots of discussions about it but i need you help with ssh remote command exit codes. I have that code: ( scan is a script which scans for viruses in the given file) for i in $FILES do RET_CODE=$(ssh $SSH_OPT $HOST "scan $i; echo $?") if [ $? -eq 0 ]; then SOME_CODE The scan works and it returns either 0 or (1 for errors) or 2 if a virus is found. But somehow my return code is always 0. Even, if i scan a virus. Here is set -x output: ++ ssh -i /home/USER/.ssh/id host 'scan