Capture Exit Code Using Pipe & Tee
- From: mthayer@xxxxxxxxxxxx
- Date: 31 Jan 2007 12:45:46 -0800
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";
system $command;
$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 appreciated.
.
- Prev by Date: Re: writing a file in IIS
- Next by Date: Why won't split() find \n?
- Previous by thread: url encode
- Next by thread: Why won't split() find \n?
- Index(es):
Relevant Pages
|