Playing around with all the options I have, I tried launching a second copy of perl, using the open HANDLE, "| program" syntax. Just piping to perl makes its own output appear in the same console as that of the parent program, but by adding "start" to the chain, it works as I'd like! It opens a second console window, that prints the messages it gets (after tweaking them a little , just to show it does something), and that stays open as long as the first program runs. It has successfully been tested on Win98.

One problem I see is with the console window title bars. The second console gets a nice title "perl", but the original program gets a pretty ugly title, consisting of the whole command line bar the pipe symbol, of the program it just started. It actually appears on the wrong console window. Oh well.

Now it's just a matter of building a tiny module that does whatever needs to be done. In the meantime, you can play with this:

#!perl -wl open FOO, qq[| start "$^X" -lne ] . q["print qq['$_' OK]"]; my $stdout = select FOO; $| = 1; select $stdout; print FOO for qw(one two three); sleep 10; print "Finished";

Update (24 hours later): Oh, damn. Though it works well on Win98, today I've had a chance to try and run it on XP, and it doesn't work there, at all. Perhaps it's a difference between the start executables on both platforms, or else, between the command line interpreters — command.exe vs. cmd.exe.

I'll have to try and use BrowserUK's version, using Windows::Console and avoiding start completely. It works on Win98, and hopefully, it'll work on XP, too. And onb anything in between.


In reply to Re: Open a second DOS window (a working possibility) by bart
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.