Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Verify FTP Success, prior to deleting files

by Anonymous Monk
on Oct 05, 2003 at 21:37 UTC ( #296791=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

NOTE: I cannot use the Net::FTP module, because I am not allowed to download any software to this production system.
How can I ensure the files are successfully ftp'ed to the $webserver prior to deleting the files?
Thanks, David
Here is my ftp & delete code:
`ftp -i -n $webserver << 'EOF' user $username $passwd cd $destdir lcd $logdir mput @delFiles quit EOF`; foreach $delfile (@delFiles) { unlink $delfile || die "could not delete $delfile $!\n"; }

Comment on Verify FTP Success, prior to deleting files
Download Code
Re: Verify FTP Success, prior to deleting files
by TVSET (Chaplain) on Oct 05, 2003 at 22:33 UTC
    How can I ensure the files are successfully ftp'ed to the $webserver prior to deleting the files?

    One of the ways could be by listing the directory on the $webserver, locating the entries for the files that were just uploaded and comparing the sizes. Of course, there is always a chance of corruption that doesn't change the size...

    Also, you can parse the log of your FTP session and make sure that server responses were positivie all the time. :)

Re: Verify FTP Success, prior to deleting files
by Roger (Parson) on Oct 05, 2003 at 23:57 UTC
    You can not 100% guarantee that the files are successfully FTP'ed to another system without checking both the source and destination copies of the files.

    I can think of a simple solution using the 'PULL' method on the client system. The process flow is as follows:

  • When a data file becomes available on the FTP server, a cronjob on the server fires off to calculate the CRC of the file and store in the same directory as the data file, with a .crc extension.
  • At certain fixed interval on the $webserver, a cronjob fires off to FTP get the data file and the .crc of the data file.
  • The client computes the CRC of the received data file and compares against the CRC calculated on the FTP server. If CRC's match, then the client will FTP delete the data from the FTP server. If CRC's do not match, then report the error or try again.

    The sender will never delete data files, only the receiver will delete them after download and CRC comparison.

Re: Verify FTP Success, prior to deleting files
by strredwolf (Chaplain) on Oct 07, 2003 at 03:19 UTC
    use Net::FTP

    --
    $Stalag99{"URL"}="http://stalag99.keenspace.com";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://296791]
Approved by adamsj
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2014-07-28 13:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (199 votes), past polls