pipes problem
From: Billy N. Patton (b-patton_at_ti.com)
Date: 09/28/04
- Next message: Abigail: "Re: Precedence of exponentiation"
- Previous message: Sherm Pendley: "Re: What is this error?"
- Next in thread: Scott W Gifford: "Re: pipes problem"
- Reply: Scott W Gifford: "Re: pipes problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Sep 2004 14:51:25 -0500
I have this bit of code:
The followfing sets $stat correctly : to 0
my $stat = 0;
$ret = undef;
$ret = `$command`;
$stat = $? >> 8;
The follow sets $stat to 1, Incorrect.
# open PIPE , "$command 2>&1 |";
# while (<PIPE>)
# {
# Lis($_);
# $ret .= $_;
# }
# $stat = close PIPE;
in book "Programming Perl" @nd Edition , Covers perl5
Page 342. Last 5 lines
the exit sataus of the child process is haaarvested by the parent
process when it eventually doeas a wait(2) system call. But this
happens in the close function, not in the open function. And that's why
you have to check the return vallue of your close function.
I tried this and got the proper return code:
close PIPE;
$stat = $? >> 8;
Even this worked:
close PIPE;
$stat = $?;
I don't understand?????
My goal here is to execute a system command and be able to capture the
stdout/stderr as it is happening. I don't like programs that simply sit
and give you no indication anything is happening.
--
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-patton@ti.com
- Next message: Abigail: "Re: Precedence of exponentiation"
- Previous message: Sherm Pendley: "Re: What is this error?"
- Next in thread: Scott W Gifford: "Re: pipes problem"
- Reply: Scott W Gifford: "Re: pipes problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|