Well this is good. But would be perfect to realy separate the STDERR from STDOUT. Probably will have diferent colors in the output. Can you get me that please.
Thanks Marcos -----Original Message----- From: zentara [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2003 1:56 PM To: [EMAIL PROTECTED] Subject: Re: Run one process and get the stdout and stderr On Thu, 16 Oct 2003 09:56:18 +0200, [EMAIL PROTECTED] (Marcos Rebelo) wrote: >I need to run one program and get the stdout and stdin from it. >If possible in real time. >Probably I need 'IPC::Open3' and 'select', but I donīt undrestand how to do >it. Here's a nice simple example: #!/usr/bin/perl use warnings; use strict; use IPC::Open3; #interface to "bc" calculator #my $pid = open3(\*WRITE, \*READ, \*ERROR,"bc"); my $pid = open3(\*WRITE, \*READ,0,"bc"); #if \*ERROR is false, STDERR is sent to STDOUT while(1){ print "Enter expression for bc, i.e. 2 + 2\n"; chomp(my $query = <STDIN>); #send query to bc print WRITE "$query\n"; #get the answer from bc chomp(my $answer = <READ>); print "$query = $answer\n"; } __END__ Our body's 20 milligrams of beta radioactive Potassium 40 emit about 340 million neutrinos per day, which go at lightspeed to the ends of the universe!..even thru the earth. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
