I have a Perl script, wot I wrote (I'm no Perl expert), which I have been using successfully for some time. One part of it downloads a log in 'resume' mode i.e it downloads only the new part and appends it to the existing log.
Just recently it has downloaded the new part of the log but it then overwrites the existing file with just the new bit although the script has not been changed???
The relevant parts of the script are shown below. I'm running Debian Sarge/Testing.
Perls of wisdom appreciated.
Barry Samuels http://www.beenthere-donethat.org.uk The Unofficial Guide to Great Britain
P.S. To anyone who read about my previous FTP problem - a router firmware upgrade cured the problem.
============================================================================== my $ftp = Net::FTP->new("mydomain.com", Passive => 1, Debug => 0); $ftp->login( $user,$password) or die "Login failed - ", $ftp->message; $ftp->cwd("/var/log/httpd") or die "Unable to change remote directory - ",$ftp->message;
chdir "/home/user/RawLogs";
my $filesize = 0; # Get size of current log. $filesize = ( -s "access_log" );
my $remotesize = 0; # Get size of remote log. $remotesize = $ftp->size("access_log");
# Download current log. # Don't transfer the first $filesize bytes (append to existing file). $ftp->get( "access_log", "access_log", $filesize );
print "Disconnecting from remote system\n"; $ftp->quit;