Hi,
Sorry about the load of code below but I though I'd best include as much as I can.
The script is peppered with print() commands to troubleshoot and i've found the only part thats not working is when it tries to enter the EVAL block towards the end.
If anyone has any ideas much appreciated.
# @(#) Script that checks last 150 session log files for any failures or errors and reports details to Production support.
# Usage: cs takes the switch "-m". This will mail, rather than report to stdout(the deault), the user calling the script.
my $scripts='/users/$USER';
my $space = " ";
my $dir = '/apps/informat5/informatica/PowerCenter/SessLogs';
my $temp = '/users/msimcox/temp';
my $time = gmtime;
my @pr_list = ();
my @pr_files = ();
my @matchlist = ();
my @matches = ();
chomp(my @matchlist = ( '^ORA',
'No such file or directory',
'failed to extend rollback segment',
'Error executing shell command...$',
'Error connecting to database...$',
'Error initializing DTM for session...$',
'An error occurred while connecting',
'TNS:could not resolve service name',
'fetched column value was truncated',
'unexpected end of SQL command',
'Received request to stop session run',
'missing expression',
'Failed to logon to Database server',
'Deadlock error encountered.',
'table or view does not exist',
'STG_PROD.CHECK_SESSION',
'failed to extend rollback segment',
'resource busy and acquire with NOWAIT specified',
'Joiner will not produce any output row'
));
@matches = map { qr/$_/ } @matchlist;
chdir "$dir" or die "Can't chdir to SessLogs: $!";
chomp(my @srcfiles = `ls -1rt | tail -170`);
foreach my $file (@srcfiles) {
my $curfile = `tail -1 $file`;
push (@pr_files, $file) if $curfile =~ /Session run completed with failure/
}
#HEADER INFORMATION
&pl("\n\tAUTOMATED SESSION LOG SEARCH RESULTS\n\t------------------------------------\n\nFiles scanned 170 Directory: $dir $space Time: $
time\n\n");
#Bare block for perl variable alteration
#Push failures onto @temp array
{
local $" = '|';
my @temp = ("Just to hold a value\n");
my @i;
print "@matches";
foreach my $file (@pr_files) {
print "Entered the file read loop\n";
open FILE, "$file" or die "Cant open file: $file";
print "Opened file $file\n";
&pl ("$file failed");
print "About to study file $file\n";
#Bare block for perl variable alteration
{
local $/ = undef;
print "Entered study section for file: $file\n";
my $hndlread = <FILE>;
study ($hndlread);
close FILE;
}
print "Left study section for file: $file\n";
#@temp = (); #reset @temp to nothing for new file
$i = 0;
print "Value held by counter i: $i.\n";
### DOES NOT ENTER EVAL COMMAND ????? ###############
eval { $hndlread =~ /(@matches)
print "Made it to the eval block\n";
(?{
print $1;
foreach (@temp) {
$i++ if ($_ eq $1);
}
push @temp, $1 if ($i = 0);
})
/gx
}
#######################################################
}
print "About to print temp array within block.\n";
foreach (@temp) {
print;
print "Entered loop to print off temp array.\n";
}
}
print "Left file read loop.\n";
&output;
#####Start of subroutines#####################
sub pl {
push @pr_list, "$_[0]";
}
sub output {
foreach (@pr_list) {
print "$_\n";
}
}
cheers
simmo
Sorry about the load of code below but I though I'd best include as much as I can.
The script is peppered with print() commands to troubleshoot and i've found the only part thats not working is when it tries to enter the EVAL block towards the end.
If anyone has any ideas much appreciated.
# @(#) Script that checks last 150 session log files for any failures or errors and reports details to Production support.
# Usage: cs takes the switch "-m". This will mail, rather than report to stdout(the deault), the user calling the script.
my $scripts='/users/$USER';
my $space = " ";
my $dir = '/apps/informat5/informatica/PowerCenter/SessLogs';
my $temp = '/users/msimcox/temp';
my $time = gmtime;
my @pr_list = ();
my @pr_files = ();
my @matchlist = ();
my @matches = ();
chomp(my @matchlist = ( '^ORA',
'No such file or directory',
'failed to extend rollback segment',
'Error executing shell command...$',
'Error connecting to database...$',
'Error initializing DTM for session...$',
'An error occurred while connecting',
'TNS:could not resolve service name',
'fetched column value was truncated',
'unexpected end of SQL command',
'Received request to stop session run',
'missing expression',
'Failed to logon to Database server',
'Deadlock error encountered.',
'table or view does not exist',
'STG_PROD.CHECK_SESSION',
'failed to extend rollback segment',
'resource busy and acquire with NOWAIT specified',
'Joiner will not produce any output row'
));
@matches = map { qr/$_/ } @matchlist;
chdir "$dir" or die "Can't chdir to SessLogs: $!";
chomp(my @srcfiles = `ls -1rt | tail -170`);
foreach my $file (@srcfiles) {
my $curfile = `tail -1 $file`;
push (@pr_files, $file) if $curfile =~ /Session run completed with failure/
}
#HEADER INFORMATION
&pl("\n\tAUTOMATED SESSION LOG SEARCH RESULTS\n\t------------------------------------\n\nFiles scanned 170 Directory: $dir $space Time: $
time\n\n");
#Bare block for perl variable alteration
#Push failures onto @temp array
{
local $" = '|';
my @temp = ("Just to hold a value\n");
my @i;
print "@matches";
foreach my $file (@pr_files) {
print "Entered the file read loop\n";
open FILE, "$file" or die "Cant open file: $file";
print "Opened file $file\n";
&pl ("$file failed");
print "About to study file $file\n";
#Bare block for perl variable alteration
{
local $/ = undef;
print "Entered study section for file: $file\n";
my $hndlread = <FILE>;
study ($hndlread);
close FILE;
}
print "Left study section for file: $file\n";
#@temp = (); #reset @temp to nothing for new file
$i = 0;
print "Value held by counter i: $i.\n";
### DOES NOT ENTER EVAL COMMAND ????? ###############
eval { $hndlread =~ /(@matches)
print "Made it to the eval block\n";
(?{
print $1;
foreach (@temp) {
$i++ if ($_ eq $1);
}
push @temp, $1 if ($i = 0);
})
/gx
}
#######################################################
}
print "About to print temp array within block.\n";
foreach (@temp) {
print;
print "Entered loop to print off temp array.\n";
}
}
print "Left file read loop.\n";
&output;
#####Start of subroutines#####################
sub pl {
push @pr_list, "$_[0]";
}
sub output {
foreach (@pr_list) {
print "$_\n";
}
}
cheers
simmo