|The stupid question is the question not asked|
Capture Exit Code Using Pipe & Teeby Anonymous Monk
|on Jan 31, 2007 at 19:44 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I have a piece of code provided below. The code calls a make command, and redirects STDOUT/STDERR to tee, which then sends it to the screen, and also to a log file. The problem is that I'm trying to capture the exit code for make. However, what happens when I run the command a cmd process starts up, and calls make and tee as peers, so make exits first, then tee, which returns the exit code of tee to cmd, and cmd returns the exit code to the script. What I need is the exit code from make, and not tee.
$command = "make -f <parameters>";
$command .= " 2>&1 | tee -a build.log";
$exit_value = $? >> 8;
print "\nExit Value: $exit_value\n\n";
The exit value is always 0, because it's returning the tee value, and not make. Any and all help is very apprciated.