hi
I have a serious problem with one script.
2 files ( AA1000020 and BB1000024 )
will be renamed ( to CC00000010 and DD000000011 ) 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 CC00000010
BB1000024 DD000000011
----------------------------------
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 ( CC00000010 )
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', 'test@domain.com') 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
ccc
I have a serious problem with one script.
2 files ( AA1000020 and BB1000024 )
will be renamed ( to CC00000010 and DD000000011 ) 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 CC00000010
BB1000024 DD000000011
----------------------------------
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 ( CC00000010 )
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', 'test@domain.com') 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
ccc