I notice several things with your code.

First, you don't show where you actually create the $creadedir var, but from the error message

error creating \\10.1.1.5\Weblogiclogs\02091812! at service.pl line 27.

it shows that you are missing off the minutes and seconds? Is this intentional? Could this be a part of your problem?

Anyway, this is more easily done using POSIX::strftime as I've shown below.

You really should get into the habit of including $! (and on Win32 boxes where the operation involves calls to the OS, $^E, see perlvar) in your error messages, it will usually tell you WHY things went wrong, as well as that they have.

As talexb says above the perlfunc:mkdir function would be better than that system call, and if your log files are currently on the same drive as their new directory, then using the built-in function perlfunc:rename will move them to their new home much more efficiently than shelling to the system move command.

use Win32::Service; my $filedir = "\\\\10.1.1.5\\Weblogiclogs"; my $IWlogs = "\\\\10.1.1.5\\Weblogiclogs\\*.log*"; # Get Local Time and Create folder based on local time stamped # This is a much easier way of creating your directory name my $createdir = strftime( '%y%d%e%H%M%S', localtime); # Create folder based on local time obtained above # - This is where the script is erroring out at.... if(!-e $createDir) { # NOTE: The $! & $^E will tell you WHY it failed. mkdir $createdir or die "Couln't create $createdir because $!($^E) +\n"; } # move logs files to new created directory named after # the local time. @args = ( "move" , $IWlogs , $createDir ) ; system( @args ) == 0 or die "error moving $IWlogs reason $!($^E)"; # +NOTE: $! & $^E

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

In reply to Re: Please help - problem with script on Win2K by BrowserUk
in thread Please help - problem with script on Win2K by Anonymous Monk

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.