E
ebm
I'm writing a script that will run as a scheduled task on a win2k
server. I would like the script to log to the Event Viewer on the
server but when I use the Win32::EventLog module I get a bunch of
garbage included in the Event that I log. Is there a away to do this
with so I don't get the garbage...
Event Type: Error
Event Source: Weekly Report Script
Event Category: None
Event ID: 100
Date: 09/26/2007
Time: 11:56:56 AM
User: N/A
Computer: LVEPL3LX620
Description:
The description for Event ID ( 100 ) in Source ( Weekly Report
Script ) cannot be found. The local computer may not have the
necessary registry information or message DLL files to display
messages from a remote computer. You may be able to use the /
AUXSOURCE= flag to retrieve this description; see Help and Support for
details. The following information is part of the event: This is a
Test Error......
------
script:
use Win32::EventLog;
my $Type = "ERROR";
my $IDNum = 100;
my $Description = "This is a Test Error.....";
chomp( $Type, $IDNum, $Description );
my %Event = (
Length => NULL,
RecordNumber => NULL,
TimeGenerated => NULL,
EventID => $IDNum,
Category => NULL,
Source => "Weekly Report Script",
Strings => $Description,
);
if ( uc($Type) eq "ERROR" ) {
$Event{'EventType'} = EVENTLOG_ERROR_TYPE;
}
elsif ( uc($Type) eq "WARN" ) {
$Event{'EventType'} = EVENTLOG_WARNING_TYPE;
}
elsif ( uc($Type) eq "INFO" ) {
$Event{'EventType'} = EVENTLOG_INFORMATION_TYPE;
}
elsif ( uc($Type) eq "AUDIT" ) {
$Event{'EventType'} = EVENTLOG_AUDIT_SUCCESS;
}
else {
$Event{'EventType'} = EVENTLOG_AUDIT_FAILURE;
}
my $LogEvent = Win32::EventLog->new("Application")
or die "Can't open Application Event Log to enter $Description\n";
$LogEvent->Report( \%Event ) or die($!);
$LogEvent->Close();
server. I would like the script to log to the Event Viewer on the
server but when I use the Win32::EventLog module I get a bunch of
garbage included in the Event that I log. Is there a away to do this
with so I don't get the garbage...
Event Type: Error
Event Source: Weekly Report Script
Event Category: None
Event ID: 100
Date: 09/26/2007
Time: 11:56:56 AM
User: N/A
Computer: LVEPL3LX620
Description:
The description for Event ID ( 100 ) in Source ( Weekly Report
Script ) cannot be found. The local computer may not have the
necessary registry information or message DLL files to display
messages from a remote computer. You may be able to use the /
AUXSOURCE= flag to retrieve this description; see Help and Support for
details. The following information is part of the event: This is a
Test Error......
------
script:
use Win32::EventLog;
my $Type = "ERROR";
my $IDNum = 100;
my $Description = "This is a Test Error.....";
chomp( $Type, $IDNum, $Description );
my %Event = (
Length => NULL,
RecordNumber => NULL,
TimeGenerated => NULL,
EventID => $IDNum,
Category => NULL,
Source => "Weekly Report Script",
Strings => $Description,
);
if ( uc($Type) eq "ERROR" ) {
$Event{'EventType'} = EVENTLOG_ERROR_TYPE;
}
elsif ( uc($Type) eq "WARN" ) {
$Event{'EventType'} = EVENTLOG_WARNING_TYPE;
}
elsif ( uc($Type) eq "INFO" ) {
$Event{'EventType'} = EVENTLOG_INFORMATION_TYPE;
}
elsif ( uc($Type) eq "AUDIT" ) {
$Event{'EventType'} = EVENTLOG_AUDIT_SUCCESS;
}
else {
$Event{'EventType'} = EVENTLOG_AUDIT_FAILURE;
}
my $LogEvent = Win32::EventLog->new("Application")
or die "Can't open Application Event Log to enter $Description\n";
$LogEvent->Report( \%Event ) or die($!);
$LogEvent->Close();