Check whether FTP is successful or not, in a Unix shell script

I want to write a Unix shell script which will ftp a file from one server to another. I want to check whether the FTP is successful or not. After the FTP is complete, I would like to check the cksum of local and remote file, to compare whether the transfer was successful. I dont want to use ssh. How can I do this?

Also, if I can print the status of each of the statements below, then it would be great.

ftp username password
<check whether you are able to login, or is there a failure>
lcd /home/abcd
<check whether this folder exists>
cd /home/efgh
<check whether this folder exists>
put a_local.txt a_remote.txt
<check the status here, whether file was completely or partially transferred>

It'll be highly impossible to interpret the ftp session and check the conditions. If you want to achieve the same try with rsh or remsh commands. Check the man pages and you can achieve the same. If you need any help regarding rsh/remsh then let me know.

Bye

0

lb2020Commented: 2010-07-08

Hi folks,
I have the same requirement i need to trap the errors in FTP transfer using unix .Iam new to unix please help me out if u have any sample code regarding this.