Greetings Old wise ones,
I am trying to write a script to save a copy of a particular EventLog(Application, System or Security)
and if the save subroutine is called again and a saved file exists, then it should add the new events to the existing log.
I am a beginner and am having a real tough time with the documentation trying to figure out how to write a new event to the saved log, in the way it was written by the initial backup method call.
Please Help!!
This is what I have for save,
sub Save
{
our $DirName = 'WinLog';
&DirCreator($DirName);
foreach (@arr)
{
my $Log_obj = Win32::EventLog->new("$_","");
$FileName = "$_\.evtx";
$Log_obj->Backup("\.\\".$DirName."\\"."$FileName");
switch ($^E)
{
case /^$/ { print "Log Successfully saved.";}
case /^Cannot\ create\ a\ file\ when\ that\ file\ already\
+ exists$/
(
<This is where Im stuck!!!>
)
else { print "Error : $^E"};
}
close ("$Log_obj");
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.