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

Hello monks

I wants to invoke several system commands in parallel manner.All these commands exists in a same script on after the other

Kindly Help me out to resolve this issue. Thanks in advance !!!

  • Comment on Calling several System commands parallely

Replies are listed 'Best First'.
Re: Calling several System commands parallely
by BrowserUk (Patriarch) on Jun 29, 2010 at 05:47 UTC

    Ostensibly,

    use threads; my @commands = ...; my @jobs = map{ async{ system $_; } } @commands; $_->join for @jobs;
Re: Calling several System commands parallely
by Khen1950fx (Canon) on Jun 29, 2010 at 04:49 UTC
    I just posted a response to a similar question not to long ago. See: Re: Parallel Processing. Here's the sample code using Parallel::Runner
    #!/usr/bin/perl use strict; use warnings; use Parallel::Runner; my $runner = Parallel::Runner->new(5); $runner->run( sub { system("corelist CGI") }); $runner->run( sub { system("corelist CGI::Carp") }); $runner->run( sub { system("corelist Net::FTP") }); $runner->run( sub { system("corelist Net::SMTP") }); $runner->run( sub { system("corelist DBI") }); $runner->finish;
Re: Calling several System commands parallely
by salva (Canon) on Jun 29, 2010 at 06:43 UTC
    use Proc::Queue size => 5, qw(system_back all_exit_ok); my @pids; push @pids, system_back $_ for @cmd; all_exit_ok(@pids) or die "some command failed";