diff --git a/src/parallel b/src/parallel index 3cb0e3e9..35030f8c 100755 --- a/src/parallel +++ b/src/parallel @@ -5387,6 +5387,8 @@ sub sshcommand_of_sshlogin { # login@host my $self = shift; my ($sshcmd, $serverlogin); + # If $SSH is unset, use 'ssh' + $ENV{'PARALLEL_SSH'} ||= "ssh"; if($self->{'string'} =~ /(.+) (\S+)$/) { # Own ssh command $sshcmd = $1; $serverlogin = $2; @@ -5395,7 +5397,7 @@ sub sshcommand_of_sshlogin { if($opt::controlmaster) { # Use control_path to make ssh faster my $control_path = $self->control_path_dir()."/ssh-%r@%h:%p"; - $sshcmd = "ssh -S ".$control_path; + $sshcmd = $ENV{'PARALLEL_SSH'}." -S ".$control_path; $serverlogin = $self->{'string'}; if(not $self->{'control_path'}{$control_path}++) { # Master is not running for this control_path @@ -5407,18 +5409,24 @@ sub sshcommand_of_sshlogin { $SIG{'TERM'} = undef; # Ignore the 'foo' being printed open(STDOUT,">","/dev/null"); - # OpenSSH_3.6.1p2 gives 'tcgetattr: Invalid argument' with -tt - # STDERR >/dev/null to ignore "process_mux_new_session: tcgetattr: Invalid argument" + # With -tt OpenSSH_3.6.1p2 gives: + # 'tcgetattr: Invalid argument' + # STDERR >/dev/null to ignore + # "process_mux_new_session: tcgetattr: Invalid argument" open(STDERR,">","/dev/null"); open(STDIN,"<","/dev/null"); - # Run a sleep that outputs data, so it will discover if the ssh connection closes. - my $sleep = ::shell_quote_scalar('$|=1;while(1){sleep 1;print "foo\n"}'); - my @master = ("ssh", "-tt", "-MTS", $control_path, $serverlogin, "perl", "-e", $sleep); + # Run a sleep that outputs data, so it will discover + # if the ssh connection closes. + my $sleep = ::shell_quote_scalar + ('$|=1;while(1){sleep 1;print "foo\n"}'); + my @master = ($ENV{'PARALLEL_SSH'}, "-tt", "-MTS", + $control_path, $serverlogin, "perl", "-e", + $sleep); exec(@master); } } } else { - $sshcmd = "ssh"; $serverlogin = $self->{'string'}; + $sshcmd = $ENV{'PARALLEL_SSH'}; $serverlogin = $self->{'string'}; } } $self->{'sshcommand'} = $sshcmd; diff --git a/src/parallel.pod b/src/parallel.pod index cee83d99..1cb648a6 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -697,9 +697,9 @@ See also: B<--line-buffer> B<--ungroup> Print a summary of the options to GNU B and exit. -=item B<--halt-on-error> I +=item B<--halt-on-error> I (alpha testing) -=item B<--halt> I +=item B<--halt> I (alpha testing) When should GNU B terminate? In some situations it makes no sense to run all jobs. GNU B should simply give up as soon @@ -1665,7 +1665,7 @@ Does not run the command but quotes it. Useful for making quoted composed commands for GNU B. -=item B<--shuf> (beta testing) +=item B<--shuf> (alpha testing) Shuffle jobs. When having multiple input sources it is hard to randomize jobs. --shuf will generate all jobs, and shuffle them before @@ -3439,6 +3439,13 @@ $SHELL. If undefined use: =back +=item $PARALLEL_SSH (alpha testing) + +GNU B defaults to using B for remote access. This can +be overridden with $PARALLEL_SSH. It can also be set on a per server +basis (see B<--sshlogin>). + + =item $PARALLEL_SEQ $PARALLEL_SEQ will be set to the sequence number of the job diff --git a/testsuite/tests-to-run/parallel-local-ssh1.sh b/testsuite/tests-to-run/parallel-local-ssh1.sh index b25a7bcb..e35418b4 100644 --- a/testsuite/tests-to-run/parallel-local-ssh1.sh +++ b/testsuite/tests-to-run/parallel-local-ssh1.sh @@ -61,6 +61,11 @@ echo '### bug #40001: --joblog and --nonall seem not to work together:' echo '### bug #40132: FreeBSD: --workdir . gives warning if . == $HOME' cd && parallel --workdir . -S lo pwd ::: "" +echo '### use function as $PARALLEL_SSH' + foossh() { echo "FOOSSH" >&2; ssh "$@"; }; + export -f foossh; + PARALLEL_SSH=foossh parallel -S 1/lo echo ::: 'Run through FOOSSH?' + echo '### test filename :' echo content-of-: > :; echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}'; diff --git a/testsuite/wanted-results/parallel-local-ssh1 b/testsuite/wanted-results/parallel-local-ssh1 index a6e668fe..35218e9b 100644 --- a/testsuite/wanted-results/parallel-local-ssh1 +++ b/testsuite/wanted-results/parallel-local-ssh1 @@ -84,6 +84,11 @@ echo '### bug #40132: FreeBSD: --workdir . gives warning if . == $HOME' ### bug #40132: FreeBSD: --workdir . gives warning if . == $HOME cd && parallel --workdir . -S lo pwd ::: "" /home/tange +echo '### use function as $PARALLEL_SSH' +### use function as $PARALLEL_SSH + foossh() { echo "FOOSSH" >&2; ssh "$@"; }; export -f foossh; PARALLEL_SSH=foossh parallel -S 1/lo echo ::: 'Run through FOOSSH?' +Run through FOOSSH? +FOOSSH echo '### test filename :' ### test filename : echo content-of-: > :; echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}'; cat :.:; rm : :.: