Re: how to get ftp logged if transmission fails (21 Views)
Occasional Contributor
shrikant g
Posts: 7
Registered: ‎10-03-2007
Message 1 of 2 (21 Views)
Accepted Solution

how to get ftp logged if transmission fails

The files that we want to monitor are sent by one server to other. These files are saved to an NFS mount directory.
Is it possible to log receiving transmission? If transmission fails how to get it logged?
Acclaimed Contributor
A. Clay Stephenson
Posts: 17,825
Registered: ‎07-16-1998
Message 2 of 2 (21 Views)

Re: how to get ftp logged if transmission fails

Your question is somewhat confusing in that you mention ftp in the title but NFS in the body. If I can assume that you really meant FTP then it's not very difficult. You can use Perl's Net::FTP module and get error checking for free.

The attached Perl script will do all the hard work for you. All you have to do is a little shell scripting.

typeset FILENAME=myfile
typeset ERRLOG=/var/tmp/ftperrs
typeset -i STAT=0 -h remhost -l mickey -p secret -B -d /aaa/bbb -t 3 ${FILENAME}
if [[ ${STAT} -ne 0 ]]
echo "Transfer of ${FILENAME} failed; status ${STAT}." >> ${ERRLOG}
exit ${STAT}

That would login to remhost as user mickey, password "secret", set binary mode, cd to /aaa/bbb and transfer "myfile". It would automatically retry up to 3 times. If the command returns 0 all is well otherwise log the error. Just like real ftp, you can create a .netrc entry so that the password does not have to be used. Invoke as -h for full usage.

If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.