Greetings, esteemed monks!

: 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

run( \@cmd, '>pty>', sub { print "$_[0]"; }, '2>', sub { chomp $_[0]; print "<b><em>$_[0]</em></b>\n"; } ) or warn("Error executing child. Child returned $?\n");
, which is pretty close to being synchronous processing of STDERR & STDOUT, comparatively speaking. I thought I could get them closer by doing
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");
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?

TIA, Terrence

_________________________________________________________________________________

I like computer programming because it's like Legos for the mind.


In reply to IPC::Run woes by OfficeLinebacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.