1753750 Members
5203 Online
108799 Solutions
New Discussion юеВ

FTP Error trapping

 
Humphrey_1
New Member

FTP Error trapping

I would like to trap all FTP error messages particularly when the network drops i.e. files are not transferred their entirety.

filedir=/informatica/7.1/fileshare/SrcFiles
ftpLogDir=/informatica/7.1/fileshare/Scripts/ftplogs
/usr/bin/ftp -n -v $HOST <&1 ${ftpLogDir}/ftp.log
quote user $USER
quote pass $PASSWD
ascii
cd $DIR
prompt
get $FILE ${filedir}/$FILE
bye
EOA

Is there a better way of trapping errors besides scanning the log files for error codes
?

3 REPLIES 3
Peter Godron
Honored Contributor

Re: FTP Error trapping

Humphrey,
you could look at using the PERL::FTP module.
Also look at the man ftpd for a better breakdown of the ftp error codes.
Quick way to check successful transfer would be checksum the file before sending and then compare against checksum with rsh.
Regards
A. Clay Stephenson
Acclaimed Contributor

Re: FTP Error trapping

By far, the easiest method is Perl's Net::FTP module. You get error checking for free. The attached script will make it very easy for you and will return a meaning error code to the shell. If 0 status is returned, all is well. You can specify the login, password, optional account, directory, binary or ASCII, and the file(s) on the command line and all you need to do is look at the status.

It will also use .netrc if available so that the password does not have to be specified.

If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: FTP Error trapping

Ooops, I should have added invoke as ftpget.pl -u for full usage. This script will even work on Windows if one the the freely available Perls is installed.
If it ain't broke, I can fix that.