inserito creazione dir config
This commit is contained in:
@@ -105,6 +105,13 @@ while ( my $line = $tail->GetLine() ) {
|
||||
. " >> Failed to create path: $outpath/SQL";
|
||||
}
|
||||
|
||||
if ( !-d "$outpath/config" ) {
|
||||
make_path "$outpath/config",
|
||||
{ mode => 0755, owner => $truser, group => $gid }
|
||||
or warn getTimeStamp("log")
|
||||
. " >> Failed to create path: $outpath/config";
|
||||
}
|
||||
|
||||
my $timestamp = getTimeStamp();
|
||||
my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix;
|
||||
if ( !move $trfile, $dest ) {
|
||||
|
||||
@@ -102,6 +102,7 @@ while ( my $line = $tail->GetLine() ) {
|
||||
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
|
||||
my $outpath = $path . $unit . "/received";
|
||||
my $trnpath = $path . $unit . "/transmitted";
|
||||
my $cfgpath = $path . $unit . "/config";
|
||||
if ( !-d "$outpath" ) {
|
||||
make_path "$outpath",
|
||||
{ mode => 0755, owner => $truser, group => $truser }
|
||||
@@ -114,6 +115,12 @@ while ( my $line = $tail->GetLine() ) {
|
||||
or warn getTimeStamp("log")
|
||||
. " >> Failed to create path: $trnpath";
|
||||
}
|
||||
if ( !-d "$cfgpath" ) {
|
||||
make_path "$cfgpath",
|
||||
{ mode => 0755, owner => $truser, group => $truser }
|
||||
or warn getTimeStamp("log")
|
||||
. " >> Failed to create path: $cfgpath";
|
||||
}
|
||||
my $timestamp = getTimeStamp();
|
||||
my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix;
|
||||
my $send = $trnpath . "/" . $filename . "_" . $timestamp . $suffix;
|
||||
@@ -129,30 +136,32 @@ while ( my $line = $tail->GetLine() ) {
|
||||
}
|
||||
my $ftp = Net::FTP->new(
|
||||
$hostname,
|
||||
Timeout => 20,
|
||||
Timeout => 10,
|
||||
Debug => 0,
|
||||
Passive => 0
|
||||
)
|
||||
or warn getTimeStamp("log")
|
||||
. " >> Cannot connect to $hostname: $@";
|
||||
if ( $ftp->login( $username, $password ) ) {
|
||||
if ( $ftp->put( $dest, $filename . $suffix ) ) {
|
||||
if ( !move $dest, $send ) {
|
||||
warn getTimeStamp("log")
|
||||
. " >> Move $dest -> $send failed: $!";
|
||||
}
|
||||
else {
|
||||
print getTimeStamp("log")
|
||||
. " >> Moved $dest -> $send.\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
warn getTimeStamp("log") . " >> Put $dest failed ",
|
||||
$ftp->message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
warn getTimeStamp("log") . " >> Cannot login ", $ftp->message;
|
||||
if ( defined $ftp ) {
|
||||
if ( $ftp->login( $username, $password ) ) {
|
||||
if ( $ftp->put( $dest, $filename . $suffix ) ) {
|
||||
if ( !move $dest, $send ) {
|
||||
warn getTimeStamp("log")
|
||||
. " >> Move $dest -> $send failed: $!";
|
||||
}
|
||||
else {
|
||||
print getTimeStamp("log")
|
||||
. " >> Moved $dest -> $send.\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
warn getTimeStamp("log") . " >> Put $dest failed ",
|
||||
$ftp->message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
warn getTimeStamp("log") . " >> Cannot login ", $ftp->message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user