sftp return codes

sftp -v b $putlist $SFTP\_ID@TARGET_SERVER

How can I get a return code if fails to put the file?

sftp -v b $getlist $SFTP\_ID@TARGET_SERVER

How can I get a return code if fails to put the file?

check the value of $?

this may return an error that is not really an error. sftp can be a pain. for example - if you had a mkdir foo in your batch script and directory foo existed, sftp would return a non-zero code. so use with caution.

if it is only one file, scp might be a better solution.