Checking for FTP complete

Hi,

I have a situation where I'm downloading multiple files from a remote system and I need to start a process after all the files are downloaded completely. How can I achieve it.

Eg.
I have 6 files, file1, file2, file3.... file6. I need to start a script scrpt1 after all the files have successfully downloaded. I'm using commmand prompt FTP scripts to download files.

I would appreciate if someone can share knowledge on the same.
Best Regards,
Nag

if all the files are in the same directory and no other file is there then you can count the files and compare it with 6.

if [ "$(ls -1 dir | wc -l)" -eq 6 ];then
 echo "all file transferred"
else
 echo "not"
fi 

if not, you can also check the existence of the files.

Hi Anchal,
Thanks for your reply, the files will be created the moment it starts FTPing, but it does not mean the FTP is complete. How do we know that the FTP is complete ?
Regards,
Nag

---------- Post updated at 10:22 AM ---------- Previous update was at 10:21 AM ----------

Hi Anchal,

Thanks for your reply, the files will be created the moment it starts FTPing, but it does not mean the FTP is complete. How do we know that the FTP is complete ?

Regards,
Nag

better way is to use advance ftp mechanism.
btw various work arround for that if you have normal ftp method.

you can capture the log and thn do grep/sed etc for finding out various messages related to transferred for failed.

something like:

count=$(grep -c "No such file or directory" ftp.log)
if [ "${count}" -eq 0 ]; then
  echo "file(s) successfully transferred."
else
  echo "unable to trasferred file(s):"
  ## if file is not found. you can grep the following message.
  grep "No such file or directory" ftp.log |awk '{print $1}' 
fi

you can also check exit codes.. after batch run..

blah blah...
if [ $? -ne 0 ];then
 echo "FTP unsuccessfull"
fi