You could use the code below, which you would use to call the multiple scripts, each with the command that you'd like output from. Have the script that is being called print the output to STDOUT, and the script below will then print the output (or you can modify it to do whatever you need with the output).
#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use Parallel::ForkManager; use Benchmark; use File::Basename; my $thisScript = basename($0); my ($infile,$scriptName); sub usage { print <<EOF; USAGE: $thisScript -infile yourFile -script scriptToInvoke EOF } my %optctl=(); usage if (!GetOptions(\%optctl, "infile=s", "script=s", "<>", \&usage) ); if (exists($optctl{"infile"}) && exists($optctl{"script"})) { $infile = $optctl{"infile"}; $script = $optctl{"script"}; } else { exit usage; } # Use for Expect debugging open INPUT,"<$infile" or die "Could not open input ($!)\n"; my @input=<INPUT>; close INPUT; my $start = new Benchmark; my ($pm,$masterList); my $maxProbes = 80; # set this to one to do one at a time $pm = new Parallel::ForkManager($maxProbes); foreach my $line (@input) { chomp $line; $pm->start and next; my $stdout = `$script \"$line\"`; chomp $stdout; print "$stdout\n"; $pm->finish; } $pm->wait_all_children; my $end = new Benchmark; my $diff = timediff($end,$start); print "Time taken was ", timestr($diff, 'all'), " seconds\n";

In reply to Re: running multiple system commands in parallel by walkingthecow
in thread running multiple system commands in parallel by incognito129

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.