This commit is contained in:
2018-05-13 17:29:04 +02:00
parent 9b7a531c35
commit d517440b7c
2 changed files with 18 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ use strict;
use DBI; use DBI;
use Getopt::Long; use Getopt::Long;
use Net::FTP; use Net::FTP;
use File::Basename qw( fileparse );
use List::Util qw( max ); use List::Util qw( max );
use Data::Dumper qw(Dumper); use Data::Dumper qw(Dumper);
use Cwd; use Cwd;
@@ -355,12 +356,18 @@ if ( $db_name ne 'asega' ) {
else { else {
$db_name = 'ase_lar'; $db_name = 'ase_lar';
} }
if ( $filename = m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i ) { # GD801
my ( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
print "$filename\n";
print "$filecsvname\n";
if ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)_\d*$/i ) {
($fileDate, $fileTime) = split( /\s/, <FILE> ); ($fileDate, $fileTime) = split( /\s/, <FILE> );
($unittype, $unit ) = split( /\s/, uc <FILE> ); ($unittype, $unit ) = split( /\s/, uc <FILE> );
$unit =~ s/;+$//; $unit =~ s/;+$//;
} elsif ( $filename = m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i ) { # GD201
my @strings = $filename =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/; print "$unit\n";
} elsif ( $filecsvname =~ m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/;
$fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];; $fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];;
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5]; $fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
$unittype = $strings[6]; $unittype = $strings[6];
@@ -369,6 +376,7 @@ if ( $filename = m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i ) { # GD801
$tooltype = 'MUX'; $tooltype = 'MUX';
} }
print "$unit\n";
while ( my $line = <FILE> ) { while ( my $line = <FILE> ) {
my ( $first, $NodeData ) = split( /;/, $line, 2 ); my ( $first, $NodeData ) = split( /;/, $line, 2 );
if ( defined $first and ( $first ne '' ) ) { if ( defined $first and ( $first ne '' ) ) {

View File

@@ -29,15 +29,16 @@ sub getUnitName { # parm => file received ($trfile)
my ($filename) = @_; my ($filename) = @_;
my ( $fileDate, $fileTime ); my ( $fileDate, $fileTime );
my ( $unittype, $unit ); my ( $unittype, $unit );
if ( $filename = m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i ) { # GD201 my ( $filenamecsv, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
my @strings = $filename =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/; if ( $filenamecsv =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i ) { # GD201
my @strings = $filenamecsv =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/;
$fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];; $fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];;
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5]; $fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
$unittype = $strings[6]; $unittype = $strings[6];
$unit = $strings[7]; $unit = $strings[7];
} else { } else {
open FILE, $filename open FILE, $filename
or warn getTimeStamp("log") . " >> Error: opening input file $filename\n"; or warn getTimeStamp("log") . " >> Error: opening input file $filename\n";
( $fileDate, $fileTime ) = split( /\s/, <FILE> ); ( $fileDate, $fileTime ) = split( /\s/, <FILE> );
( $unittype, $unit ) = split( /\s/, uc <FILE> ); ( $unittype, $unit ) = split( /\s/, uc <FILE> );
$unit =~ s/;+$//; $unit =~ s/;+$//;
@@ -75,7 +76,8 @@ while ( my $line = $tail->GetLine() ) {
if ( ( ( uc $suffix ) eq ( uc $ext ) ) if ( ( ( uc $suffix ) eq ( uc $ext ) )
and and
( $filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d*|GD\d*)$/i ) ) ( $filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d*|GD\d*)$/i
or $filename =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i) )
{ {
my $unit = getUnitName($trfile); my $unit = getUnitName($trfile);
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n"; print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
@@ -107,7 +109,7 @@ while ( my $line = $tail->GetLine() ) {
my @fname = ($dest); my @fname = ($dest);
chown $uid, $gid, @fname; chown $uid, $gid, @fname;
if ( ($filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i if ( ($filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i
or $filename =~ m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i) or $filename =~ m/^(\d\d_\d\d\d\d_|)(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i)
and ( $unit ne 'ID9999' ) and ( $unit ne 'ID9999' )
and ( $truser ne 'corra' ) ) and ( $truser ne 'corra' ) )
{ {