http://www.perlmonks.org?node_id=553718

cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Good day Monks. I have a set of six Perl apps (running on Windows) that talk to one another through sockets. I want them to run in different command windows so I can keep an eye on stuff they're writing to stdout. Currently I get this to happen by manually opening six windows one at a time and starting a differnt app in each one.

I am tired of doing this and want to write a script that will start everything for me automatically, but I can't figure out how to do it. A perl script using the system function won't work and neither will a dos batch file because those both try to use the same process. I have not tried fork because I'm not sure creating child processes is really what I want to do.

I'd be grateful if someone could point me in the right direction.

Steve

  • Comment on Can I auto-launch multiple perl apps in different command windows?

Replies are listed 'Best First'.
Re: Can I auto-launch multiple perl apps in different command windows?
by Albannach (Monsignor) on Jun 05, 2006 at 23:25 UTC
    You can use a batch file with the START command (HELP START at your command prompt for details). I use this frequently to start multiple Perl processes each in its own command window.

    --
    I'd like to be able to assign to an luser

Re: Can I auto-launch multiple perl apps in different command windows?
by tinita (Parson) on Jun 06, 2006 at 08:47 UTC
    you can also use screen for things like that. depends on how you want to see the output.

    update: oh, sorry, i didn't read the 'windows' for some reason...

Re: Can I auto-launch multiple perl apps in different command windows?
by Scrat (Monk) on Jun 06, 2006 at 14:29 UTC

    Depending on your scripts you're running you can use Win32::Process where you can launch more than one program.

    Here's a simple example:

    #!/usr/bin/perl use warnings; use strict; use Win32; use Win32::Process; my $ProcessObj; Win32::Process::Create($ProcessObj, "C:\\perl\\bin\\perl.exe", "perl c:\\script1.pl", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); sleep 2; Win32::Process::Create($ProcessObj, "C:\\perl\\bin\\perl.exe", "perl c:\\script2.pl", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); exit; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); }

    Will execute 2 perl scripts 2 seconds apart. Hope it helps.

Re: Can I auto-launch multiple perl apps in different command windows?
by ambrus (Abbot) on Jun 06, 2006 at 18:26 UTC

    You can write their output in different logfiles and then tail -F them in different windows.