in reply to Clearcase and Perl Problem
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
|
|---|