develooper Front page | perl.beginners | Postings from April 2002

Re: calling another perl program and printing output in real time

Thread Previous
From:
drieux
Date:
April 1, 2002 19:29
Subject:
Re: calling another perl program and printing output in real time
Message ID:
CD388483-45E9-11D6-AE7F-0030654D3CAE@wetware.com

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/p1_read_p2.txt

On Monday, April 1, 2002, at 02:49 , Roy Peters wrote:

> Hello,
>
> I have 2 independent perl programs p1 and p2. p1 calls p2 (using either 
> the
> system() or `` operators, and p2 will print
> out status information every 2 seconds or so. How do I set it up such
> that whenever p2 prints out data, it is printed out by p1 also IN REAL 
> TIME?

I don't think you can do it that way, but you might want to
remember that 'open' will also works like popen() in 'c', et al.

system is about 'execing' a sub process - and that is not
always easy to deal with getting it to open a pipe back to
the process that is waiting...

If p1 needs to process other requests, to which this p2 process
is actually supposed to be a forked child.... who needed to
open a pipe back... then you have to go open up the Net:: stuff....

ciao
drieux

---

and for the purists - in the above text we do a old school
'c' style while loop with chomp - and , ok, I confess, the
cooler perlie style

	chomp, <doSomething>
		while(<INPUT>) ;


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About