OfficeLinebacker has asked for the wisdom of the Perl Monks concerning the following question:
: How to use a psuedoterminal for both STDERR && STDOUT while doing something slightly different w/each?
I'll admit I posted a similar node but it degraded into a discussion of whether my code was readable and not the issue at hand. I'm looking for a fresh start so here goes. (I've also run the code through perltidy :) )
I'd like to use a pty to trick the called program (usually another perl script) into thinking it's interacting with a tty on both STDERR and STDOUT to get the output as synchronously as possible (but I know it'll never be perfect).
I'll just post the one relevant line here, and before you ask, yes I'm using strict! LOL
What I'm doing now is
, which is pretty close to being synchronous processing of STDERR & STDOUT, comparatively speaking. I thought I could get them closer by doingrun( \@cmd, '>pty>', sub { print "$_[0]"; }, '2>', sub { chomp $_[0]; print "<b><em>$_[0]</em></b>\n"; } ) or warn("Error executing child. Child returned $?\n");
but, alas, '>pty>' really means '&>pty>'. So nothing ever makes it to my STDERR processor. Is there a way to have two separate ptys? Put '2>pty>' first?run( \@cmd, '>pty>', sub { print "$_[0]"; }, '2>pty>', sub { chomp $_[0]; print "<b><em>$_[0]</em></b>\n"; +} ) or warn("Error executing child. Child returned $?\n");
TIA, Terrence
_________________________________________________________________________________
I like computer programming because it's like Legos for the mind.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPC::Run woes
by OfficeLinebacker (Chaplain) on Jun 07, 2006 at 15:02 UTC |