All, I am Windows SysAdmin with Zero knowledge of Perl. It has fallen into my lap to fix a script that worked on Server 2003, that no longer works "properly" in 2008 R2.

This is ActivePerl 5.16.3 Build 1603 (64-bit).

The issue is where it attempt to modify a log file. Here is the output:

Tue Jul 23 09:46:43 2013 (1374598003): THREAD-0: ERROR: Cannot rotate log file C:\faa\logs to path C:\faa\logs\QA-ENC04A_flashEnc.20130723094643.log: error code=Permission denied Failed in opening log file C:\faa\logs - using STDERR

The path is correct, and the logged in user has permissions to the file system, so I am not sure why I am getting the error.

Here is the code from the sript:

# Rotate old log file. rotateLogFile(); if ($configOptions{'logFilePath'}) { $LOG_FILE_PATH = $configOptions{'logFilePath'}; } if (!isLocalLoggingEnabled() && !$DEBUGMODE) { print "NOTE: Local logging disabled in script configuration fi +le\n"; } # Make sure we can log to a log file, if necessary. if ($LOG_FILE_PATH) { my $logFileHandle = getLogFileHandle(1); closeLogFileHandle($logFileHandle); } sub getLogFileHandle { my $logErrors = shift; # If no log file, use STDERR if (!$LOG_FILE_PATH) { return \*STDERR; } my $logFileHandle = IO::File->new(">>$LOG_FILE_PATH"); if (!(defined $logFileHandle)) { $logFileHandle = \*STDERR; if ($logErrors) { print STDERR "Failed in opening log file $LOG_FILE_PATH - +using STDERR\n"; } } autoflush $logFileHandle 1; return $logFileHandle; }

Any wisdom you can provide me with would be greatly appriciated.


In reply to WinAdmin needs help w/ File System STDERR and by ReturnOfTheYeti

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.