Ok, I am getting frustrated with this... Any help is appreciated.
Step back, breathe, eat a sandwich, go for a walk... now try again...
[FTP Script]
#!/usr/bin/perl
use strict; # always use warnings; # usually
The longer you avoid the above after having been told the shorter your help time frame may be....
# Create datestamp variable use POSIX qw(strftime); $date = strftime('%Y%m%d', localtime());
ok got the date....
# Create archive using TAR & GZIP system('tar -cf ../backups/www.tar ../www/'); system('gzip -fv9 ../backups/www.tar'); system('mv -fv ../backups/www.tar.gz ../backups/' . $date . '-www.tar.gz');
Yikes, IPC at its worst, no full paths, no error code checking, the above three lines may work, but are hideous. Check out:
perldoc Archive::Tar perldoc Compress::Zlib perldoc -f rename
Please let's do this in Perl or switch to a shell script.... Assuming you have correct these then we basically end up with a file zipped tar file right?
# Begin FTP Transaction
use Net::FTP;
$ftp = Net::FTP->new("server.test", Debug => 1)or die "Could not establish connection to server.test: $@";
$ftp->login("username", 'password')or die "Could not login ", $ftp->message;
#foreach my $list(glob('*-www.tar.gz')) { # $ftp->ls($list)or die "Could not list files ", $ftp->message; }
foreach my $file(glob('../backups/*-www.tar.gz')) { $ftp->put($file) or die "Could not transfer files ", $ftp->message; }
Ok, now we are putting files... Which is fine, but are we assuming there is only one? aka the one we created above? If so we don't need the glob/loop (though it shouldn't hurt anything either).
$ftp->quit;
It says transfered in the output when you connect to server.test to see the file, the name & size descriptors are in place but when you try to extract the file it is corrupted with a CRC error. The error is this...
CRC Failed in 'name of file'. The file is corrupt
CRC is most likely related to your gzip failing, do the sizes of the files match exactly (byte for byte not the human readable sizes). This is one reason why we need to check the return codes of calls made through 'system' (or use the provided modules instead).
WTF, is it the transfer mode of Net::FTP? I have tried using ASCII & Binary modes to move the file and if you are on the machine that this perl script is running it extracts all the files just fine... Am I missing something here?
If the systems are different types then you should probably use binary mode, otherwise it shouldn't matter, but isn't likely to hurt.
Any help is appreciated.
Does any of this help, I don't believe it is the FTP causing the problem, have you tried FTP'ing the file that is left behind to the remote location and seeing if it will unzip?
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>