There probably isn't a way to do it with one process. However, you can use one process to display whatever is sent through a socket (or named pipe ...) and just connect STDERR to the socket. E.g. here's the program to show the output:
#!perl -w # usage: showerr.pl port use IO::Socket; use strict; $| = 1; $SIG{CHLD} = 'IGNORE'; my $localport = shift; my $socklisten = IO::Socket::INET->new(LocalPort => $localport, Listen => 2, Reuse => 1, Proto => 'tcp') or die "Cannot open sock on $localport: $!\n"; while (my $readport = $socklisten->accept) { print "Accepted new connection at ", scalar(localtime), "\n"; print while <$readport>; print "Connection closed at ", scalar(localtime), "\n"; }
You can start that program independently or you could have the main program start it as below (in which case you would want to take out the outer while loop (replace while with if)):
#!perl -w use IO::Socket; use strict; my $errsocket = "1999"; system("start showerr.pl 1999"); sleep(5); *STDERR = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "localhost:$errsocket", Timeout => 30, ) or die "cannot create socketremote: $!\n"; warn "This is a test"; print STDERR "testing\n"; sleep(10);
Note that there's an awkward sleep() here to wait an undetermined time for the listener to start. This race condition could be fixed, but it might be simpler to just run the showerr program independently first.

In reply to Re: Open a second DOS window by Thelonius
in thread Open a second DOS window by bart

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.