Hello all!
Just wanted to say thanks in advanced for your help...
What I'm trying to do is create a perl script that will
do the following....I think the code is correct below,
but need further help.
Desire result when running the script:
- move all logs older than 7 days from a share on a remote
server ( \\Testserver01\WeblogicLogs) to a folder
that the script will create based on local time and
date,
- in the process of moving the logs, it will automatically
zip it up (with winzip), and name it based on local date
and time. I still haven't figured out how to do this
with winzip command line option.
- Accomplished all this remotely via UNC. Do I have
to use the win32::Lanman module for this to work?
Please look at the code below and help me with step 1,2,3.
thanks again!
########################################################
# Moving files from one location to
# another, creating folder based on local time stamped
#
# (did not do yet: zipped logs up based on time stamp and
# put in the folder.)
########################################################
my $filedir = "\\\\TESTSERVER01\\Weblogiclogs\\";
my $IWlogs = "\\\\TESTServer01\\Weblogiclogs\\*.log*";
# get timestamp to name a file yymmddhhmiss.txt
($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
$mon = (1,2,3,4,5,6,7,8,9,10,11,12)[$mon];
if($mon < 10){$mon = "0" . $mon;} # add a leading zero to one-
+digit months
if($mday < 10){$mday = "0" . $mday;} # add a leading zero to one-di
+git days
if($hour < 10){$hour = "0" . $hour;} # add a leading zero to one-di
+git hours
if($min < 10){$min = "0" . $min;} # add a leading zero to one-
+digit minutes
if($sec < 10){$sec = "0" . $sec;} # add a leading zero to one
+-digit seconds
$dirname = substr($year,1,3) . $mon . $mday . $hour . $min . $sec;
$createDir = $filedir . "\\" . $dirname;
if(!-e $createDir)
{
@args = ( "mkdir", $createDir);
system(@args) == 0 or die "error creating $createDir!";
}
# move log files to new directory
@args = ( "move"
, $IWlogs
, $createDir
)
;
system( @args ) == 0 or die "error moving $IWlogs!";
Edit: Added <code> and <ol> tags. larsen
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.