inserito creazione dir config

This commit is contained in:
2020-11-13 20:29:35 +01:00
parent 20fd892060
commit 5988453a5a
2 changed files with 35 additions and 19 deletions

View File

@@ -105,6 +105,13 @@ while ( my $line = $tail->GetLine() ) {
. " >> Failed to create path: $outpath/SQL"; . " >> 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 $timestamp = getTimeStamp();
my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix; my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix;
if ( !move $trfile, $dest ) { if ( !move $trfile, $dest ) {

View File

@@ -102,6 +102,7 @@ while ( my $line = $tail->GetLine() ) {
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n"; print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
my $outpath = $path . $unit . "/received"; my $outpath = $path . $unit . "/received";
my $trnpath = $path . $unit . "/transmitted"; my $trnpath = $path . $unit . "/transmitted";
my $cfgpath = $path . $unit . "/config";
if ( !-d "$outpath" ) { if ( !-d "$outpath" ) {
make_path "$outpath", make_path "$outpath",
{ mode => 0755, owner => $truser, group => $truser } { mode => 0755, owner => $truser, group => $truser }
@@ -114,6 +115,12 @@ while ( my $line = $tail->GetLine() ) {
or warn getTimeStamp("log") or warn getTimeStamp("log")
. " >> Failed to create path: $trnpath"; . " >> 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 $timestamp = getTimeStamp();
my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix; my $dest = $outpath . "/" . $filename . "_" . $timestamp . $suffix;
my $send = $trnpath . "/" . $filename . "_" . $timestamp . $suffix; my $send = $trnpath . "/" . $filename . "_" . $timestamp . $suffix;
@@ -129,12 +136,13 @@ while ( my $line = $tail->GetLine() ) {
} }
my $ftp = Net::FTP->new( my $ftp = Net::FTP->new(
$hostname, $hostname,
Timeout => 20, Timeout => 10,
Debug => 0, Debug => 0,
Passive => 0 Passive => 0
) )
or warn getTimeStamp("log") or warn getTimeStamp("log")
. " >> Cannot connect to $hostname: $@"; . " >> Cannot connect to $hostname: $@";
if ( defined $ftp ) {
if ( $ftp->login( $username, $password ) ) { if ( $ftp->login( $username, $password ) ) {
if ( $ftp->put( $dest, $filename . $suffix ) ) { if ( $ftp->put( $dest, $filename . $suffix ) ) {
if ( !move $dest, $send ) { if ( !move $dest, $send ) {
@@ -157,5 +165,6 @@ while ( my $line = $tail->GetLine() ) {
} }
} }
} }
}
exit(0); exit(0);