Confirm file copy

Need to check whether the source file(FTP'ed file) is completly copied or not such that I can further action on the same. I have created the below script to achieve this by checking for every 10secs to whether file size is same or not but it may create a problem if the file transfer is slow and if file size doesnt changes after 10secs , I may end up with copying the incomplete file.
Appreciate your ideas on the same.

#!/bin/ksh
file_nm=$1
no_of_tries=5
sleeptime=10
curr_file_size() {
ls -l $file_nm | awk '{print $5}'
}

if [  -f $file_nm  ]
then
no_of_tries=5
sleeptime=10
for i in `seq $sleeptime`
do
prev_file_size=`curr_file_size`
sleep $sleeptime
if  [  $prev_file_size -eq `curr_file_size` ]
then
echo file is copied completly
exit
else
echo file is being copied
fi
done
else
echo file does not exists
fi

A similar post here.

The best way to know would be using a temporary extension file ftping and rename the file once completely done by ftp itself.

Hi Kumaran,
Thanks for the quick reply on this, your suggestions seems to be ok but is there any other way to achieve the same as our source is not capable of creating the extension or other flag after completly copying the file.

Regards ,
Palani

You will have to used fuser to check if the file is current opened by any user (here it would be ftp user). Or to use lsof..

But i think what we suggested is the best way and it is so simple, because ftp commands will provide such a facility with ease.

Thanks a lot for your prompt and useful reply on this, will try to use these options.