parallel: added $PARALLEL_SSH.

This commit is contained in:
Ole Tange 2015-05-10 22:23:13 +02:00
parent 31564e97fc
commit 2549b9ba1a
4 changed files with 35 additions and 10 deletions

View file

@ -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;

View file

@ -697,9 +697,9 @@ See also: B<--line-buffer> B<--ungroup>
Print a summary of the options to GNU B<parallel> and exit.
=item B<--halt-on-error> I<val>
=item B<--halt-on-error> I<val> (alpha testing)
=item B<--halt> I<val>
=item B<--halt> I<val> (alpha testing)
When should GNU B<parallel> terminate? In some situations it makes no
sense to run all jobs. GNU B<parallel> 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<parallel>.
=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<parallel> defaults to using B<ssh> 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

View file

@ -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 {}) > {}.{.}';

View file

@ -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 : :.: