Hi all,
i have written a code to ftp a file from one server to other.The ftp is happeneing successfully,but i am not able to capture the return code,to check if ftp has failed.
plz help me to find out the return code....this is urgent
below is the code i have written
#--------------------------------------------------------------------#
#Start the ftp session
#--------------------------------------------------------------------#
ftp -n $DEST_HOSTS << END
quote user $LOGIN
quote pass $PASSWORD
cd $DEST_DIR
ascii
mput $SRC_FILE
END
quit
rc=$?
echo "Return Code:$rc"
if [ $rc -ne 0 ]
then
echo "$ScriptName: Error in ftp the file $SRC_FILE to $DEST_HOSTS"
exit 1
fi
#-----------------------------------------------------------------------#
with your code, i think "quit" is going to the shell, and since it's not a shell command, you get a nonzero return code, eevn when ftp is done. (its just that ur ftp process will lie there)
when i am trying to do this i am getting the following error
ftp -nv $hostname << END
quote user $UID
quote pass $pwd
binary
put $source_file
rc=$?
echo "Return Code:$rc"
if [ $rc -ne 0 ]
then
echo "$ScriptName: Error in ftp the file $SRC_FILE to $DEST_HOSTS"
exit 1
fi
quit
END
error------->220 $hostname FTP server (SunOS 5.8) ready.
331 Password required for $UID.
230 User $UID logged in.
200 Type set to I.
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
221 Goodbye.
ftp -nv $hostname << END
quote user $UID
quote pass $pwd
binary
put $source_file
quit
END
rc=$?
echo "Return Code:$rc"
if [ $rc -ne 0 ]
then
echo "$ScriptName: Error in ftp the file $SRC_FILE to $DEST_HOSTS"
exit 1
fi