1748235 Members
3607 Online
108759 Solutions
New Discussion юеВ

ftp checking

 
haeman
Frequent Advisor

ftp checking

I have a script to use ftp to transfer file from local server to remote server ( the command is put ) regularly , if I want to log what files are successful / unsuccessful transferred , and then re-transer these unsuccesful files , can advise what can i do ? thx
10 REPLIES 10
Shrikant Lavhate
Esteemed Contributor

Re: ftp checking

Hi,

You can have checksum tally for both files. Get cheksum value of source file and match it with chksum of trasferred file. If both matches then ftp is sucessful. check manpage for more details

#man cksum
Will it remain a personal, if I broadcast it here!
Davis Paul
Valued Contributor

Re: ftp checking

Hi Haeman
Check the following example:

#!/usr/bin/sh
ftp -n -v rac1 <>/var/ftpmsg
user root root123
cd /swift
delete $D
bye
!

Here /var/ftpmsg having the logs.

Thanks and regards,
Davis Paul.
haeman
Frequent Advisor

Re: ftp checking

thx Shrikant L,

I do not have password in remote server ( the remote server is hosted by other company ) , what can i do ? thx
Shrikant Lavhate
Esteemed Contributor

Re: ftp checking

Also, you can have ftp clients from this site: http://hpux.connect.org.uk to ensure smooth n sucessful trasfer.
Will it remain a personal, if I broadcast it here!
James R. Ferguson
Acclaimed Contributor

Re: ftp checking

Hi:

If you want to verify your transfer, and you want to use FTP, enable verbose logging ('-v') and parse the session's messages for a successful transfer. Beware that the content of the message may vary depending on the FTP used on the target server.

Better than that, use Perl's Net::FTP module. This makes error checking simple.

Yet another (better) alternative is to use SFTP. You can do this in a shell; let the SFTP fail on error; and use its return code ($?) to assess the success or failure of the operation.

Testing the source and destination file's checksum is fine *IF* your transfer is a binary one or for ASCII transfers, the end-of-line controls don't change. Hence, a Unix/Windows ASCII transfer is doomed to have its checksums mismatch.

Regards!

...JRF...
haeman
Frequent Advisor

Re: ftp checking

thx reply

#!/usr/bin/sh
ftp -n -v rac1 <>/var/ftpmsg
user root root123
cd /swift
delete $D
bye
!

it seems log the connection , what I would like is what files has been transfered and re-transfer if it was unsuccessful , could advise what can i do ? thx
haeman
Frequent Advisor

Re: ftp checking

thx reply,

If you want to verify your transfer, and you want to use FTP, enable verbose logging ('-v') and parse the session's messages for a successful transfer. Beware that the content of the message may vary depending on the FTP used on the target server.

Better than that, use Perl's Net::FTP module. This makes error checking simple.

Yet another (better) alternative is to use SFTP. You can do this in a shell; let the SFTP fail on error; and use its return code ($?) to assess the success or failure of the operation.

Testing the source and destination file's checksum is fine *IF* your transfer is a binary one or for ASCII transfers, the end-of-line controls don't change. Hence, a Unix/Windows ASCII transfer is doomed to have its checksums mismatch.

-------------------------------
I think this is good suggestions , but I am not too familiar with script writing , it may have difficult for me , except use ftp , can advise what is another way to transfer file that I can make sure the files has been successfuly transfered ? if need , I can ask the administrator to login ID to do checksum .

thx advise .

Arturo Galbiati
Esteemed Contributor

Re: ftp checking

Hi,
as already suggested you can check teh retrun code or error message redirecting the output (stderr and stin) in afile and check it.
BTW the best way to be sure about the copy of teh file is (after the put) to get back the file copied with another name and perform a cksum or cmp or diff of the files.
In this way you are sure that teh file has been correctly copied.
Just my .02$
HTH,
Art
Dennis Handly
Acclaimed Contributor

Re: ftp checking

>Arturo: BTW the best way to be sure about the copy of the file is (after the put) to get and perform a cksum or cmp or diff of the files.

This probably works best when using "bin" to copy the files. Or both HP-UX.