Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

eventclear.pl

by RayRay459 (Pilgrim)
on Dec 28, 2001 at 00:35 UTC ( #134713=sourcecode: print w/replies, xml ) Need Help??
Category: NT Admin
Author/Contact Info Ray Espinoza
Description: This will clear local event log on a machine. No backup, just clear. We use this for machines that are ghosted and cleaned up for production.
# Ray Espinoza
# eventclear.pl
# This will clear the local eventlog to be used in the update.cmd scri
+pt for new builds.
######################################################################
+##################

#!/usr/bin/perl 
    use Win32::EventLog;
    use strict;
    
    my ($Event, $filename, $directory);
    $directory = 'c:/temp/';
    
    for ('System', 'Security', 'Application')    {
        $Event = new Win32::EventLog ("$_", "") || die "can't create o
+bject\n";
        $filename = $directory . $_ . '.evt';
        print " $filename exists\n" if (-e "$filename");
        $Event->Clear($filename)or warn " $!";
        $Event->Close();
        
            } 
Replies are listed 'Best First'.
Re: eventclear.pl
by chip (Curate) on Dec 28, 2001 at 06:06 UTC
    Very nice. But... I have to take off 0.2 style points, 0.1 each for two useless quotations of variables. There's no point in saying "$_"; $_ will quite suffice.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: eventclear.pl
by Anonymous Monk on Dec 28, 2001 at 02:28 UTC
    Sweet, quick cheap and easy. I love it.
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://134713]
help
Chatterbox?
[tye]: hey, thezip!
[RonW]: Hi, tye, thezip
[RonW]: I see useless errors liek that from Perl programs, too.
[tye]: well, you certainly don't see strack traces with all of the values removed from Perl.
[thezip]: Howdy RonW. Not in *my* logfiles you won't!
[tye]: and I never claimed anything about 100% on either side.
[RonW]: Presumably because the coders didn't realize that die and warn will append line number and file when the message strings doesn'r end with a line terminator
[tye]: And these are popular and not new python projects.
[thezip]: I had a user complain that they didn't receive an email from one of my processes. I went to the logfile and reproduced the entire contents of the email they would have received. Not my problem.
[tye]: How the heck does a web framework get popular when an unexpected exception gets logged as just "Exception" w/ no details?

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-09-21 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (252 votes). Check out past polls.

    Notices?