Title: Message
Thanks Gary, but that is only half the battle.  The main obstacle is finding the next instance of the $pid after the current one.  I.e. given the following piece of log:
 
Application exception occurred:
        App: netsc_us.exe (pid=69332)
        When: 10/12/2001 @ 13:26:36.172
        Exception number: c0000005 (access violation)
 
*----> System Information <----*
        Computer Name: NODISEOSL2K
......
*----> Task List <----*
   0 Idle.exe
   8 System.exe
 176 SMSS.exe
69332 netscape.exe
2316 talkback.exe
69424 DRWTSN32.exe
   0 _Total.exe
 
Then I want to print out this:
 
App: netsc_us.exe (pid=69332)
        69332 netscape.exe
        When: 10/12/2001 @ 13:26:36.172

      Exception number: c0000005 (access violation)
 
and do this each time I match the string "App: " in the log.
 
Thanks for your help!
 
Nikko
********************************************
Interwoven, Inc.
Moving Business to the Web

Nikko Odiseos
Technical Support Engineer
Direct Line: (408)530-7175
Main Line: (408) 774-2000
Email: [EMAIL PROTECTED]
Web: http://www.interwoven.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Gary MacDonald
Sent: Monday, December 03, 2001 10:56 AM
To: [EMAIL PROTECTED]
Subject: RE: Parsing pids from drwtsn.log

I've removed the unnecessary foreach loop and the $line variable.  I'm assuming that 2152 OUTLOOK.exe is at the beginning of a line.
 
The trick is to use the capturing capability of the regex.
 
        $pid = '00000';  # invalid PID
        while (<DRWTSN>) {   
            if (($pid) = /App\:.+pid=(\d+)/) {
                print  "<b>$_</b><br>";
            }
            if (/^$pid\s/) {
                print "$_<br>";
            }
            if (/When\:/) {
                print "$_<br>";
            }
            if (/Exception\Snumber\:/) {
                print "$_<br><br><br>";
            }
          }  
Gary
-----Original Message-----
From: Nikko Odiseos [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 03, 2001 11:33 AM
To: [EMAIL PROTECTED]
Subject: Parsing pids from drwtsn.log

I am trying to parse the dr watson log and trying to get it so that when it fines the pid that generated an exception it looks from that place in the log and looks for the next instance of the pid string and prints it out. 
 
Right now it prints out this:
App: mmc.exe (pid=2152)
When: 11/28/2001 @ 11:42:46.513
 
But I want it to print out this:
App: mmc.exe (pid=2152)
2152 OUTLOOK.exe
When: 11/28/2001 @ 11:42:46.513
 
What I have so far is this:
 
$drwt = "C:/Documents and Settings/All Users.WINNT/Documents/DrWatson/drwtsn32.log";
print  "<a name=\"drwatson\"></a><br>";
print   "<b>Dr Watson Log</b><br>";
if (-e $drwt) {
     open (DRWTSN, $drwt) ;
        while (<DRWTSN>) {   
        foreach $line (<DRWTSN>) {
               if ($line =~ /App\:/) {
               print  "<b>$line</b><br>";
               }
               if ($line =~ /When\:/) {
                print "$line<br>";
               }
               if ($line =~ /Exception\Snumber\:/) {
                print "$line<br><br><br>";
               }
          }  

 close DRWTSN;
 }
else {
print  "No Dr Watson Log in All Users.WINNT\Documents\DrWatson";
}
Thanks for any help!

Reply via email to