EventLog Gets Runtime Exception Error 
Author Message
 EventLog Gets Runtime Exception Error

This one is driving me crazy. Any help would be greatly appreciated.
When I attempt to read the event log the second time my script blows up
with "Error: Runtime Exception". Here is a test script I wrote that is
successful printing the Application log messages. When it tries to do it
the second time it blows up. I am running build -522 and EventLog.pm
0.062.

#!perl -w

use Win32::EventLog;


 &getevts;

Quote:
}

sub getevts() {
 print "Printing $type Event Log\n";
 sleep 2;
 my ($x) = 0;
 my ($EventLog)=Win32::EventLog->new($type, $ENV{ComputerName}) or die
"Error: $!\n";
 $EventLog->GetNumber(my ($recs)) or die "Error: $!\n";
 $EventLog->GetOldest(my ($base)) or die "Error: $!\n";
 while ($x < $recs) {
  $EventLog->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ, $base+$x,
my ($event)) or die "Error: $!\n";
  Win32::EventLog::GetMessageText($event);
  print "Message: $event->{Message}\n";
  $x++
 }
 $EventLog->Close();
Quote:
}



Thu, 20 Jun 2002 03:00:00 GMT  
 EventLog Gets Runtime Exception Error
I figured it out. The documentation seems to be wrong. This Close statement
resolved my problem:

Win32::$EventLog->Close();

I don't think it was getting closed properly and I had unpredictable
results.

Joe

Quote:

> This one is driving me crazy. Any help would be greatly appreciated.
> When I attempt to read the event log the second time my script blows up
> with "Error: Runtime Exception". Here is a test script I wrote that is
> successful printing the Application log messages. When it tries to do it
> the second time it blows up. I am running build -522 and EventLog.pm
> 0.062.

> #!perl -w

> use Win32::EventLog;



>  &getevts;
> }

> sub getevts() {
>  print "Printing $type Event Log\n";
>  sleep 2;
>  my ($x) = 0;
>  my ($EventLog)=Win32::EventLog->new($type, $ENV{ComputerName}) or die
> "Error: $!\n";
>  $EventLog->GetNumber(my ($recs)) or die "Error: $!\n";
>  $EventLog->GetOldest(my ($base)) or die "Error: $!\n";
>  while ($x < $recs) {
>   $EventLog->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ, $base+$x,
> my ($event)) or die "Error: $!\n";
>   Win32::EventLog::GetMessageText($event);
>   print "Message: $event->{Message}\n";
>   $x++
>  }
>  $EventLog->Close();
> }



Fri, 21 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP! Runtime Exception Error

2. Error : Runtime exception with Win32::ODBC

3. Error : Runtime exception with win32Api...

4. Error: Runtime Exception <-- on longrunning sub

5. Runtime exception error, PerlApp

6. Error: Runtime Exception <-- on longrunning sub

7. Error: Runtime exception

8. Trying to add exception handling, getting errors after adding Error.pm to path

9. Runtime exception with Win32::ODBC

10. gdwin32 doesn't appear to work (Runtime Exception)

11. runtime exception in activestate perl when using modules

12. Pattern match causing runtime exception

 

 
Powered by phpBB® Forum Software