Hello, I'm trying to webify a windows event log script. This script works fine when run from a command line on the server running IIS, but when run as a CGI using CGI.PM it returns the following error: Bad file descriptor at C:\Inetpub\wwwroot\cgi-bin\login.pl line 99.
line 99: $EventLog->GetOldest(\$first) || die $!;
I believe this is might be a permissions problem but not sure where to look anyone have any ideas? Thanks in advance! Subroutine:
sub server_events { print_header(); print"<h2>SysAdmin Tools v0.1 (beta) </h2>\n"; my $servername = $q->param('servername') || 'localhost'; my $eventtype = $q->param('eventtype') || 'System'; my $eventquan = $q->param('eventquan') || '10'; print qq{<b>$servername is Server </b><br>}; print qq{<b>$eventtype is Event Type </b><br>}; print qq{<b>$eventquan is Event Quantity </b><br>}; my ($EventLog, $count, $first, $key); $first = $count = 0; my $event={ 'Source' => NULL, 'Computer' => NULL, 'Length' => NULL, 'Category' => NULL, 'RecordNumber' => NULL, 'TimeGenerated' => NULL, 'Timewritten' => NULL, 'EventID' => NULL, 'EventType' => NULL, 'ClosingRecordNumber' => NULL, 'Strings' => NULL, 'Data', => NULL, }; $EventLog = new Win32::EventLog( "$eventtype","$servername" ) || d +ie $!; $EventLog->GetOldest(\$first) || die $!; $EventLog->GetNumber(\$count) || die $!; $EventLog->Read((EVENTLOG_SEEK_READ | EVENTLOG_BACKWARDS_READ),$fi +rst+$count,$event); for my $i ($first+$count-$eventquan+1..$first+$count) { $EventLog->Read((EVENTLOG_SEQUENTIAL_READ|EVENTLOG_BACKWARDS_READ) +,0,$event); my ($sec,$min,$hour,$mday,$mon,$year,$sday,$yday,$isdst) = localti +me($event->{'TimeGenerated'}); print sprintf("%15s -> %02d\-%02d\-%02d, %02d:%02d\n",'timestamp', +$year,$mon+1,$mday,$hour,$min); #to get a readable EventId $event->{'EventID'} = $event->{'EventID'} & 0xffff; foreach $key ('RecordNumber','Category','Source','EventID', 'Event +Type', 'Strings', 'Data') { print sprintf( "%15s -> %s\n",$key, $event->{$key} ); print "<br>" } print "\n<br>"; } }

In reply to win32::eventlog file descriptor errors on IIS Server by jrdeinhard

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.