LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   [Perl] brainstorming with pipes & commands (http://www.linuxquestions.org/questions/programming-9/%5Bperl%5D-brainstorming-with-pipes-and-commands-197327/)

patator 06-24-2004 04:39 PM

[Perl] brainstorming with pipes & commands
 
Hi all !
I have something like that :

open(FH,"command1 | command2 | command3 |");

These three commands must run together.
*command1 send on stdout a stream that command2 and command3 process
*BUT command1 send a progress in % on stderr and I MUST get it.
( I can't run command1 separately => creating a 5Go file !!! )

HOW CAN I DO THAT ????

->doing an:
open(FH,"command1 2>error.txt | command2 | command3 |");
and reading+processing error.txt ?

->CAN PERL DO SOMETHING LIKE THIS ?
## wrong code !!

1) open(PIPE);
2) open(FH,"command1 2>PIPE | command2 | command3 |");
3) while(<PIPE>) {
process the stderr
}

Well, I've been searching for 2 days but I can't find anything suitable.
Have an idea of something equivalent ?????

BIG THANX for your answers !! ;o)=
Patator da FiRsT

david_ross 06-24-2004 04:51 PM

Welcome to LQ.

Can't you just read in from <STDER>?

aluser 06-24-2004 06:22 PM

Try IPC::Open3. (perldoc IPC::Open3) I think it's installed by default, could be wrong.

I don't think that reading from <STDERR> is going to work.

patator 06-25-2004 04:17 AM

BIG THANX aluser !!!!
IPC::Open3 does a wonderfull job !!!!! ;o)=
That's so easy now !!!

THANX All !

Patator da FiRsT


All times are GMT -5. The time now is 10:05 AM.