Exit codes in SFTP

HI All,
I have created a unix script which takes 2 parameters and using sftp tranfers files to remote location
following is the script

#!/bin/ksh
#
#
# Parameter 1 is the complete path of the destination server
# Parameter 2 is the complete path of the file which is to be FTP
#-----------------------------------------------------------------
DEST_SERV=host@xxx.xxsftp.xx.com
FTP_STR=`sftp $DEST_SERV << EOF
echo $?
cd $1
echo $?
put $2
echo $?
quit
EOF`
echo --- $FTP_STR

i need to know the exit codes after each command is executed so tht i can trap it.
My problem is tht even if the put filename or directory path is invalid the exit code is returned as "0".
Can you pls help me.

Thanks a lot
Vikram.
****************

Vikram,
What you wanted to do with "FTP_STR" ? If you really looking that way as an option to get exit status then remove that back-quotes and run the sftp block as it is. After the block i.e. EOF, you can get exit-status by traditional $?
In your code you always getting "0" because that status seems of FTP_STR assignment (=)