I am using the following code to parse through a log file and match words on
two sequential lines. I would like to add some code to it to check three
sequential lines.  I have tried several things but with not luck. Could
someone please take a look at the code at let help me with this.



Thank you in advance
Lance


#/usr/bin/perl

#open a file with the filehandle
open WORKFLOW, "+<..\\..\\workflow.txt"  or die "Cannot open Workflow $!\n";

for(my $i=0; $i<22; $i++){<WORKFLOW>};   #This will put you at row 23.----
  $_=<WORKFLOW>;                                        #set the var for the first line
  my $nextline = <WORKFLOW>;                    #set the var for the second line
  my $thirdline =<WORKFLOW>;                    #set the var for the third line
if ((substr($_, 42, 7) eq "Running") and (substr($nextline, 42, 7) eq
"Running")and (substr($thirdline, 42, 7))
{
        open (APPEND, ">>Moniterlog.log") or die "$! error trying to append";
        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
        %weekday=(
        "0"=>"Sunday",
        "1"=>"Monday",
        "2"=>"Tueday",
        "3"=>"Wednesday",
        "4"=>"Thursday",
        "5"=>"Friday",
        "6"=>"Saturday",
        "7"=>"Sunday",
        );
      if ($hour> 12)
      {
        print APPEND "Successfully Completed Work Flow Moniter
$hour:$min\n";
        print APPEND 'Substring: '.substr($_, 42, 7);
        print APPEND "\n";
        print APPEND 'Substring: '.substr($nextline, 42, 7);
        print APPEND "\n";
        print APPEND "----------------------------------------------------\n";
        }
      else
      {
        print APPEND "Successfully Completed Work Flow Moniter
$hour:$min\n";
        print APPEND 'Substring: '.substr($_, 42, 7);
        print APPEND "\n";
        print APPEND 'Substring: '.substr($nextline, 42, 7);
        print APPEND "\n";
        print APPEND "----------------------------------------------------\n";
      }
}
else
{

    use Mail::Sendmail;                    #Send and email if there are
errors
    %mail = ( To      =>  '[EMAIL PROTECTED]',
            From    =>  '[EMAIL PROTECTED]',
            Subject =>  '',
            Message =>  'Work Flow ended: '.substr($line, 95, 17)
           );
   sendmail(%mail) or die $Mail::Sendmail::error;
   print "OK. Log says:\n", $Mail::Sendmail::log;
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to