It's difficult to be sure what you want, but I think you're running into the problem that a standard open() call doesn't read STDERR from its child.

If all you need is to capture STDERR as well as STDIN, you ought to be able to use shell redirection:

open TEMP,"cleartool checkout -nc $element_pathname 2>&1 |" or die "Failed to checkout: $!"; # Read from TEMP as usual, but now we also have STDERR

If you need to be able to distinguish between STDIN and STDERR, your best bet is probably to use IPC::Open3.

use IPC::Open3; my $pid = open3 IGNORE,TEMPOUT,TEMPERR, 'cleartool',"checkout -nc $element_pathname" or die "Failed to open3: $!"; # first read from TEMPERR while (<TEMPERR>) { # open3 returns an exec error on the error fh you gave it /^open3:/ && die "Error in open3: $_"; # Check for the cleartool error message here } while (<TEMPOUT>) { print "The message is - $_"; } # Don't forget to reap it! waitpid $pid,0;

Possibly easier would be using shell redirection to direct each of STDOUT and STDERR into files, and then reading from the files. You might check out perlfaq8 for general info on this stuff, although I couldn't find anything that had a decent open3 example.

echo "Get some open3 examples in the docs\n" | cat >>TODO

-dlc


In reply to Re: Clearcase and Perl Problem by dchetlin
in thread Clearcase and Perl Problem 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.