This is PerlMonks "Mobile"

Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  


in reply to Open a second DOS window

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.

Replies are listed 'Best First'.
Re: Re: Open a second DOS window (a working possibility)
by BrowserUk (Patriarch) on Oct 09, 2003 at 23:26 UTC

    Try this

    #! perl -plw use strict; use Win32::Console; BEGIN{ my $c=new Win32::Console( STD_ERROR_HANDLE ); $c->Free(); $c->Alloc(); } END{ print 'Paused'; 1 while sleep 1; }

    Name that as Errcon.pl and then do

    perl -e"open F, '| perl ErrCon.pl' or die $!; print F 'Hello world', $ +_, $/ for 1 .. 100"

    You'll need to use ^Break to end the progam.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail