diff --git a/doc/FUTURE_IDEAS b/doc/FUTURE_IDEAS index 810b42d2..e33eb099 100644 --- a/doc/FUTURE_IDEAS +++ b/doc/FUTURE_IDEAS @@ -4,21 +4,8 @@ One jobqueue per sshlogin. -parallel '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 - -# Should work: -parallel --onall -S eos,iris '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 - -parallel -S eos '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 -parallel -S iris '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 - -parallel -a /tmp/abc -a /tmp/123 -S eos '(echo {3} {2}) | awk \{print\ \$2}' -parallel -a /tmp/abc -a /tmp/123 -S iris '(echo {3} {2}) | awk \{print\ \$2}' - cat | parallel --onall -S eos,iris '(echo {3} {2}) | awk \{print\ \$2}' :::: - ::: a b c ::: 1 2 3 - - vmstat\ 1\ 2\ \|\ tail\ -n1\ \|\ awk\ \{print\\\ \\\$7*\\\$8\} diff --git a/src/parallel b/src/parallel index 78810c2f..1d78a2f7 100755 --- a/src/parallel +++ b/src/parallel @@ -61,15 +61,23 @@ if($::opt_nonall or $::opt_onall) { } # for each sshlogin do: # parallel -S $sshlogin $command :::: @argfiles - open(PARALLEL,"| parallel -j $::opt_P") || die; + # + # Pass some of the options to the sub-parallels, not all of them as + # -P should only go to the first, and -S should not be copied at all. + my $options = + ((defined $::opt_u) ? "-u" : " ") . + ((defined $::opt_g) ? "-g" : " ") . + ""; + ::debug("| parallel $options"); + open(PARALLEL,"| parallel $options -P $::opt_P") || die; for my $sshlogin (values %Global::host) { - print PARALLEL "parallel -j1 -S ". + print PARALLEL "parallel $options -j1 -S ". shell_quote_scalar($sshlogin->string())." ". shell_quote_scalar($command)." :::: @argfiles\n"; } close PARALLEL; unlink(@argfiles); - exit; + wait_and_exit(min(undef_as_zero($Global::exitstatus),254)); } $Global::JobQueue = JobQueue->new( @@ -316,22 +324,9 @@ sub acquire_semaphore { return $sem; } -sub get_options_from_array { - # Run GetOptions on @array - # Returns: - # true if parsing worked - # false if parsing failed - # @array is changed - my $array_ref = shift; - # A bit of shuffling of @ARGV needed as GetOptionsFromArray is not - # supported everywhere - my @save_argv; - my $this_is_ARGV = (\@::ARGV == $array_ref); - if(not $this_is_ARGV) { - @save_argv = @::ARGV; - @::ARGV = @{$array_ref}; - } - my @retval = GetOptions +sub options_hash { + # Returns a hash of the GetOptions config + return ("debug|D" => \$::opt_D, "xargs|m" => \$::opt_m, "X" => \$::opt_X, @@ -421,6 +416,24 @@ sub get_options_from_array { "Y|shebang|hashbang" => \$::opt_shebang, "skip-first-line" => \$::opt_skip_first_line, ); +} + +sub get_options_from_array { + # Run GetOptions on @array + # Returns: + # true if parsing worked + # false if parsing failed + # @array is changed + my $array_ref = shift; + # A bit of shuffling of @ARGV needed as GetOptionsFromArray is not + # supported everywhere + my @save_argv; + my $this_is_ARGV = (\@::ARGV == $array_ref); + if(not $this_is_ARGV) { + @save_argv = @::ARGV; + @::ARGV = @{$array_ref}; + } + my @retval = GetOptions(options_hash()); if(not $this_is_ARGV) { @{$array_ref} = @::ARGV; @::ARGV = @save_argv; diff --git a/src/parallel.pod b/src/parallel.pod index c16fde1b..b31fd93c 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -621,13 +621,16 @@ See also B<-X> for context replace. If in doubt use B<-X> as that will most likely do what is needed. -=item B<--onall> (unimplemented) +=item B<--onall> (alpha testing) Run all the jobs on all computers given with B<--sshlogin>. GNU B will log into B<--jobs> number of computers in parallel and run one job at a time on the computer. The order of the jobs will not be changed, but some computers may finish before others. +When using B<--group> the output will be grouped by each server, so +all the output from one server will be grouped together. + =item B<--output-as-files> diff --git a/testsuite/tests-to-run/test60.sh b/testsuite/tests-to-run/test60.sh new file mode 100644 index 00000000..d704798f --- /dev/null +++ b/testsuite/tests-to-run/test60.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SERVER1=parallel-server3 +SERVER2=parallel-server2 + +echo '### Test --onall' +parallel --onall -S parallel@$SERVER2,$SERVER1 '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 +parallel --onall -S parallel@$SERVER2,$SERVER1 -u '(echo {3} {2}) | awk \{print\ \$2}' ::: a b c ::: 1 2 3 + +echo '### Test --nonall' +parallel --nonall -S parallel@$SERVER2,$SERVER1 'hostname' +parallel --nonall -S parallel@$SERVER2,$SERVER1 -u 'hostname;sleep 2;hostname' + diff --git a/testsuite/wanted-results/test60 b/testsuite/wanted-results/test60 new file mode 100644 index 00000000..92dca977 --- /dev/null +++ b/testsuite/wanted-results/test60 @@ -0,0 +1,44 @@ +### Test --onall +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +1 +2 +3 +2 +1 +3 +2 +3 +1 +1 +2 +2 +3 +3 +1 +2 +3 +### Test --nonall +nlv.pi.dk +vh2.pi.dk +nlv.pi.dk +vh2.pi.dk +nlv.pi.dk +vh2.pi.dk