Operating System - HP-UX
1752619 Members
4300 Online
108788 Solutions
New Discussion

Re: how to get ftp logged if transmission fails

 
SOLVED
Go to solution
shrikant g
Occasional Contributor

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?
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

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.

#!/usr/bin/sh
typeset FILENAME=myfile
typeset ERRLOG=/var/tmp/ftperrs
typeset -i STAT=0
ftpput.pl -h remhost -l mickey -p secret -B -d /aaa/bbb -t 3 ${FILENAME}
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Transfer of ${FILENAME} failed; status ${STAT}." >> ${ERRLOG}
fi
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 ftpput.pl -h for full usage.

If it ain't broke, I can fix that.