Return Value from a FTP shell script

Hello folks,,,
I am calling a Unix shell script from java. The unix script is transferring a file through FTP. I wonder how can I confirm whether the script has been executed properly without any error. Is there any way to find the return value from the script.

My FTP script is given below

#!/bin/ksh
MAINDIR=/some/directory
INPUT_FILENAME_1=$1;
INPUT_FILENAME_2=$2;
SOURCE_FILE_NAME_1=$MAINDIR/$INPUT_FILENAME_1
SOURCE_FILE_NAME_2=$MAINDIR/$INPUT_FILENAME_2
REMOTEDIR=/remote/dir/
FTP_SERVER_1=server_name
USER_NAME=******
PASSWORD=******
export MAINDIR INPUT_FILENAME_1 INPUT_FILENAME_2 SOURCE_FILE_NAME_1 SOURCE_FILE_NAME_2 REMOTEDIR FTP_SERVER_1 USER_NAME PASSWORD
ftpFile()
{
server=$1
echo FTP STARTED at $(date)
echo $server
ftp -in <<FTP 
open $server
user $USER_NAME $PASSWORD
binary
cd $REMOTEDIR
put $SOURCE_FILE_NAME_1 $INPUT_FILENAME_1
put $SOURCE_FILE_NAME_2 $INPUT_FILENAME_2
bye
FTP
echo FTP COMPLETED at $(date)
}
ftpFile $FTP_SERVER_1;

Please help!! Thanks in advance

Do it with Perl, not a shell script.

See examples at my Perl Net::FTP

Hi Tony,
Thanks for ur reply..I am not working with Perl..I need it in ksh only

FTP produces error codes it does not return a failure status to the shell unless it has an internal error.

The error codes have to be parsed to get what you want:
FTP Error Codes Explained
And occur during normal processing.