I'm not sure about AIX, but the following worked for me on Linux, and it took less than 6 seconds:
#!/usr/bin/perl
use warnings;
use strict;
my @commands = ( 'sleep 3 && find /usr/share/doc',
'sleep 4 && find /opt',
'sleep 5 && df' );
my @pids;
for my $i (0 .. $#commands) {
if (my $pid = fork) {
push @pids, $pid;
} elsif (defined $pid) {
0 == system "$commands[$i] > $i.o" or die "Can't run $commands
+[$i]";
exit
} else {
die "Can't fork";
}
}
for my $i (0 .. $#commands) {
print "=== $commands[$i] ===\n";
waitpid $pids[$i], 0;
open my $fh, '<', "$i.o" or die "$i.o: $!";
print while <$fh>;
unlink "$i.o";
}
The output from the first command goes first, etc.
Update
Or, without temporary files:
#!/usr/bin/perl
use warnings;
use strict;
my @commands = ( 'sleep 3 && find /usr/share/doc',
'sleep 4 && find /opt',
'sleep 5 && df' );
my @fhs;
for my $i (0 .. $#commands) {
open $fhs[$i], '-|', $commands[$i] or die "Can't run $commands[$i]
+";
}
for my $i (0 .. $#commands) {
print "=== $commands[$i] ===\n";
print while readline $fhs[$i];
}
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|