# Use -*- perl -*- mode in Emacs. #-------------------------------------------------------------------------------- $RC{configs} = ['dnl', 'abme', 'bet', 'khae', ], $RC{model_root} = '/nfs/fm/disks/fm_aaaa_00011/users/me/repotest/model/tools/someproject/logs' 1; #### #!/usr/5.14.1/bin/perl -w use strict; use warnings; use FileHandle; use File::Find; use Getopt::Long; use Data::Dumper; use File::Path; use Safe; use vars qw($ProgDir $ProgName $debug $quiet %RC %OPTS %OPTS_DEF); main (); sub main { parse_cmdline (); read_file($OPTS{rcfile}) if exists $OPTS{rcfile}; dynamo_check (); } my $configs = $RC{configs}; my $model_root = $RC{model_root}; my $outputfile = 'output.txt'; my %results; myPrint("Executing the script: $ProgName"); myPrint("$ProgName executed successfully"); #------------------------------------------------------------------------------- sub dynamo_check { #look for 'Errors: 0' string here my $log_file = $model_root; while ( <$log_file> ) { my ( $varname, $value ) = ( m/\A(\S+) = \'(\S+)\'/ ); if ( $varname eq '$RC{model_root}' ) { $model_root = $value; } } #print $model_root; foreach my $log_file ( glob "/*" ) { info ("Opening file: $log_file"); my $fh = open_for_reading ($log_file); if ($log_file eq "dynamo."){ while(my $line = <$fh>) { last if ($line =~ m/s*=\s+Exiting Dynamo\W/); chomp $line; open (my $ofh, '>' , $outputfile) or printError ("Could not open this file $!"); if ($line =~ m/Errors:\s+0/) { print $ofh "Dynamo run status: PASS\n"; $results{'Dynamo'} = "PASS"; }else { print $ofh "Dynamo run status: FAILED\n"; $results{'Dynamo'} = "FAILED"; } close $fh; } } #add this file to the 'reports' directory } } info ("done..check 1");