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 Getopt::Long;
use Net::FTP;
use File::Basename qw( fileparse );
use List::Util qw( max );
use Data::Dumper qw(Dumper);
use Cwd;
@@ -355,12 +356,18 @@ if ( $db_name ne 'asega' ) {
else {
$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> );
($unittype, $unit ) = split( /\s/, uc <FILE> );
$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];;
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
$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';
}
print "$unit\n";
while ( my $line = <FILE> ) {
my ( $first, $NodeData ) = split( /;/, $line, 2 );
if ( defined $first and ( $first ne '' ) ) {

View File

@@ -29,8 +29,9 @@ sub getUnitName { # parm => file received ($trfile)
my ($filename) = @_;
my ( $fileDate, $fileTime );
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 @strings = $filename =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/;
my ( $filenamecsv, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
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];;
$fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5];
$unittype = $strings[6];
@@ -75,7 +76,8 @@ while ( my $line = $tail->GetLine() ) {
if ( ( ( uc $suffix ) eq ( uc $ext ) )
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);
print getTimeStamp("log") . " >> Unit $unit - Filename $trfile\n";
@@ -107,7 +109,7 @@ while ( my $line = $tail->GetLine() ) {
my @fname = ($dest);
chown $uid, $gid, @fname;
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 ( $truser ne 'corra' ) )
{