hi
I need really HELP
this perl script opens and reads the info file,
renames the first file, sends via ftp,
waits 15 minutes, renames the second file and sends via ftp
info file looks:
----------------------------
XX10000022 VV000000011
YY1000022 ZZ0000000012
----------------------------
all files are TEXTfiles.
the problem is, it sends both files to the same directory.
how to change this script, to send the second file to the different fixed directory,
than the first one ?
use strict;
use warnings;
use Net::FTP;
# change directory
chdir "/ftp/files" or die "/ftp/files: $!\n";
# DO NOT transfer without info file
-f "/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;
# 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', '****@domain.net') or
die "$_: cannot logon: " . $ftp->message;
# change remote directories
my $cwd_performed = 0;
if ($cwd_performed) {
$ftp->cwd("FTP/IN/FIRST")
}
else {
$ftp->cwd("FTP/IN/SECOND") if (!$cwd_performed++)
}
# Put first file to the ftp server
$ftp->put ($2) or
die "$server: cannot put $2: " . $ftp->message;
$ftp->quit;
sleep (15 * 60)
}
I need really HELP
this perl script opens and reads the info file,
renames the first file, sends via ftp,
waits 15 minutes, renames the second file and sends via ftp
info file looks:
----------------------------
XX10000022 VV000000011
YY1000022 ZZ0000000012
----------------------------
all files are TEXTfiles.
the problem is, it sends both files to the same directory.
how to change this script, to send the second file to the different fixed directory,
than the first one ?
Code:
#!/usr/bin/perl -w use strict;
use warnings;
use Net::FTP;
# change directory
chdir "/ftp/files" or die "/ftp/files: $!\n";
# DO NOT transfer without info file
-f "/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;
# 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', '****@domain.net') or
die "$_: cannot logon: " . $ftp->message;
# change remote directories
my $cwd_performed = 0;
if ($cwd_performed) {
$ftp->cwd("FTP/IN/FIRST")
}
else {
$ftp->cwd("FTP/IN/SECOND") if (!$cwd_performed++)
}
# Put first file to the ftp server
$ftp->put ($2) or
die "$server: cannot put $2: " . $ftp->message;
$ftp->quit;
sleep (15 * 60)
}
Code: