I'm looking for a perlscript to compare size of 2 files
hi
I need a perl script to compare size of 2 files ( same names ) on 2 different ftp server and if NOT the same size send a mail to administrator. regards cccc |
Try:
Code:
#!/usr/bin/perl |
thank you very much !
|
hi david_ross
I have a serious problem with one script. 2 files ( AB1000020 and CA1000024 ) will be renamed ( to DE00000010 and EF000000011 ) according to a INFO file and sent via ftp, first the first one file and 5 minutes later the second one. info file looks: ---------------------------------- AB1000020 DE00000010 CA1000024 EF000000011 ---------------------------------- I cannot send the second file without the first one. I have to be 100% sure, that the first one one file was completely transferred. how to change this script, after first file was sent, to compare the size of the first file ( DE00000010 ) locally at /var/ftp/files and on the ftp server and only then send the second file ? #!/usr/bin/perl use strict; use warnings; use File::Copy; use Net::FTP; use Net::Netrc; # change directory chdir "/var/ftp/files" or die "/var/ftp/files: $!\n"; # DO NOT transfer without info file -f "/home/ftp/files/info" or die "info file is missing\n"; open(FILE, "<info>"); while (<FILE> ) { s/\W*$//; next if (!$_); /^(.+?) \s+ (.+?)$/x; my ($old, $new) = ($1, $2); rename $old, $new; # rename files # ftp transfer my $server = "X.X.X.X"; my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3); $ftp or die "$server: cannot connect: $@"; # If you don't use ~/.netrc $ftp->login ('anonymous', 'address@domain.net') or die "$_: cannot logon: " . $ftp->message; # Put files to the ftp server $ftp->put ($2) or die "$server: cannot put $2: " . $ftp->message; sleep ( 5 * 60 ) } kind regards cccc |
I haven't used Net:FTP but from the documentation it looks like there is a "size" command:
http://theoryx5.uwinnipeg.ca/CPAN/da...FTP.html#size_(_FILE_) |
thanks, but can't find how to do that.
greetings cccc |
All times are GMT -5. The time now is 05:15 AM. |