Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Execute progams in parallel

by kalyanrajsista (Scribe)
on Jan 20, 2010 at 06:07 UTC ( #818379=perlquestion: print w/ replies, xml ) Need Help??
kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I've a set of Perl programs to be executed in Parallel from a Perl script. I'm working on Windows. Is there any CPAN Module (or) Code available to do the task

Comment on Execute progams in parallel
Re: Execute progams in parallel
by Marshall (Prior) on Jan 20, 2010 at 06:42 UTC
    I recommend looking at http://ss64.com/nt/, in particular the "start" command.

    On WinXP type "help start" at the command prompt.

Re: Execute progams in parallel
by Anonymous Monk on Jan 20, 2010 at 07:07 UTC

      I'm interested in getting the PID of the commands, but program is printing the PID's after completion of the program we've executed from Proc::background.

      I'm working on Windows and when I check my Task Manager for all the processes, It is showing perl.exe processes but not my Perl programs.Any alternative to check if the program CreatePerson.pl or CreateCountry.pl are running or not.

      #!/usr/bin/perl use strict; use warnings; use Proc::Background; use Config; my $secure_perl_path = $Config{perlpath}; if ($^O ne 'VMS') {$secure_perl_path .= $Config{_exe} unless $secure_perl_path =~ m/$Config{_exe}$/i }; my $command1 = "$secure_perl_path $ENV{'source'}/src/CreatePerson.pl"; my $command2 = "$secure_perl_path $ENV{'source'}/src/CreateCountry.pl" +; foreach ( $command1, $command2 ) { my $proc = Proc::Background->new("$_ &"); print $proc->pid(),"\n"; }
        How about something like:
        #!/usr/bin/perl use strict; use warnings; use Proc::Background; use Config; my $secure_perl_path = $Config{perlpath}; if ($^O ne 'VMS') {$secure_perl_path .= $Config{_exe} unless $secure_perl_path =~ m/$Config{_exe}$/i }; my $command1 = "$secure_perl_path $ENV{'source'}/src/CreatePerson.pl"; my $command2 = "$secure_perl_path $ENV{'source'}/src/CreateCountry.pl" +; my @processes; foreach ( $command1, $command2 ) { my $proc = Proc::Background->new("$_ &"); push @processes, $proc; } while(1){ my $at_least_one_alive = 0; for my $proc(@processes){ if($proc->alive()){ print "'" . $proc->pid . "' is still alive"; $at_least_one_alive = 1; } sleep(1); #or however long you would like. } last if ! $at_least_one_alive; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2014-09-16 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (17 votes), past polls