trapping sftp errors

I'm trying to trap errors in a shell script executing an sftp command this way:

/usr/bin/sftp $FTP\_USER@$FTP_SERVER <<EOF> $HOME/$ERR_FILE
cd $FTP_DIR
put $FILE_NAME
bye
EOF

I expect errors to be recorded in $ERR_FILE but they are not. The only thing in the $ERR_FILE is:
sftp> sftp> sftp>

Thank you

Errors might be printed to standard error instead of standard output, try 2> instead of >

I made the change you suggested and that did it. Thanks a lot.:slight_smile: