Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by cormanaz (Chaplain)
on Jun 05, 2006 at 22:56 UTC ( #553718=perlquestion: print w/ replies, xml ) Need Help??
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?
Re: Can I auto-launch multiple perl apps in different command windows?
by Albannach (Prior) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://553718]
Approved by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2015-07-04 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls