On 25 Jun 2001 16:18:05 -0500, Tom Yarrish wrote:
> Okay, just for clarification. The line from the log file was word
> wrapped. It does show on one line in the actual file.
> Second, the pattern I am trying to match is exactly how it is in the m//
> statement. So it is all caps, and it's those three words I'm trying to
> match.
> Also, I should have said the first time, I did make sure that the $status
> variable had the regex in it (doing the print "Foo: $status" example). It
> just started happening once I added in the else part of the section.
>
> Thanks,
> Tom
<snip />
> > > open(TAIL, "tail $glmiss_log|") or die "Can't tail on $glmiss_log: $!\n";
> > >
> > > while (my $status = <TAIL>){
> > > if ($status =~ /SERVICE NOT AVAILABLE/){
> > > print "Service not running, attempting to start.\n";
> > > print "This may take a few minutes.\n";
> > > $fix = 1;
> > > } else {
> > > print "Service is connected.\n";
> > > $fix = 0;
> > > exit;
> > > }
> > > }
> > >
> > > Okay, the $glmiss_log points to a logfile, and for test purposes I'm using
> > > one that has the "Service not available" error at the end of it. So the
> > > first part of the if statement should pick it up. Here's what the error
> > > looks like in the log:
> > >
> > > WARNG 05:02:10 VCI_Login : TECH_VCI_ERROR 00120 - EXCHANGE SERVICE NOT
> > > AVAILABLE
> > >
> > > Now if I put [] around the regex, it matches it, but without it skips and
> > > goes right to the else statement. Do I need to put any pattern matching
> > > for the rest of the line? I basically just need it to see this error
> > > (which if there's a problem will be the last line in the log file) and
> > > then I have it do something once it exits the loop.
> > >
> > > Thanks ahead of time,
> > > Tom
<snip />
Are you certain that all lines in your log have "SERVICE NOT AVAILABLE"
in them? If there is even one in the tail that does not have the string
in it you will hit the else clause and exit. Also, are you certain you
don't want tail -f (tail with the follow changes to the file) instead of
just tail?
--
Today is Boomtime, the 31st day of Confusion in the YOLD 3167
P'tang!