Hi,

I'm writing Perl program to execute 'nmake' command. I'm looking for the best way to execute the 'nmake' command from Perl program on Unix and to get the return value From the Unix shell. Finally, I want to print the error to log file and to the screen.

Currently I have written the following code and its work fine:
open (LOG, "> $buildLog") || die "-E- Can't open (write) the log file: + $buildLog\n($!)\n"; tee(STDOUT, '>>', $buildLog); tee(STDERR, '>>', $buildLog); $status = system ("nmake /f $object.mak CFG=\"$object - ${BUILD_CFG}$b +uild_config\""); if ($status) { TraceLog ("---------------------------------------"); TraceLog ("-E- nmake ended with errors! (status=$status)"); TraceLog ("---------------------------------------"); print ; &sendBuildFailure ($object); close (LOG); exit 1;
The question is if it's correct to "send" all STDOUT & STDERR to log file in that way? And after I pass successfully that function how can I continue the script without print all to log file (Stop the 'tee' function) due to the command below:
tee(STDOUT, '>>', $buildLog); tee(STDERR, '>>', $buildLog);
Please advice. Let me know if you need more information's. Thanks

In reply to Get Return Value from Unix by Noame

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.