mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
parallel: Implemented --ssh.
This commit is contained in:
parent
2549b9ba1a
commit
d4c347c22b
11
src/parallel
11
src/parallel
|
@ -741,6 +741,7 @@ sub options_hash {
|
||||||
"sshlogin|S=s" => \@opt::sshlogin,
|
"sshlogin|S=s" => \@opt::sshlogin,
|
||||||
"sshloginfile|slf=s" => \@opt::sshloginfile,
|
"sshloginfile|slf=s" => \@opt::sshloginfile,
|
||||||
"controlmaster|M" => \$opt::controlmaster,
|
"controlmaster|M" => \$opt::controlmaster,
|
||||||
|
"ssh=s" => \$opt::ssh,
|
||||||
"return=s" => \@opt::return,
|
"return=s" => \@opt::return,
|
||||||
"trc=s" => \@opt::trc,
|
"trc=s" => \@opt::trc,
|
||||||
"transfer" => \$opt::transfer,
|
"transfer" => \$opt::transfer,
|
||||||
|
@ -5387,8 +5388,8 @@ sub sshcommand_of_sshlogin {
|
||||||
# login@host
|
# login@host
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($sshcmd, $serverlogin);
|
my ($sshcmd, $serverlogin);
|
||||||
# If $SSH is unset, use 'ssh'
|
# If $opt::ssh is unset, use $PARALLEL_SSH or 'ssh'
|
||||||
$ENV{'PARALLEL_SSH'} ||= "ssh";
|
$opt::ssh ||= $ENV{'PARALLEL_SSH'} || "ssh";
|
||||||
if($self->{'string'} =~ /(.+) (\S+)$/) {
|
if($self->{'string'} =~ /(.+) (\S+)$/) {
|
||||||
# Own ssh command
|
# Own ssh command
|
||||||
$sshcmd = $1; $serverlogin = $2;
|
$sshcmd = $1; $serverlogin = $2;
|
||||||
|
@ -5397,7 +5398,7 @@ sub sshcommand_of_sshlogin {
|
||||||
if($opt::controlmaster) {
|
if($opt::controlmaster) {
|
||||||
# Use control_path to make ssh faster
|
# Use control_path to make ssh faster
|
||||||
my $control_path = $self->control_path_dir()."/ssh-%r@%h:%p";
|
my $control_path = $self->control_path_dir()."/ssh-%r@%h:%p";
|
||||||
$sshcmd = $ENV{'PARALLEL_SSH'}." -S ".$control_path;
|
$sshcmd = $opt::ssh." -S ".$control_path;
|
||||||
$serverlogin = $self->{'string'};
|
$serverlogin = $self->{'string'};
|
||||||
if(not $self->{'control_path'}{$control_path}++) {
|
if(not $self->{'control_path'}{$control_path}++) {
|
||||||
# Master is not running for this control_path
|
# Master is not running for this control_path
|
||||||
|
@ -5419,14 +5420,14 @@ sub sshcommand_of_sshlogin {
|
||||||
# if the ssh connection closes.
|
# if the ssh connection closes.
|
||||||
my $sleep = ::shell_quote_scalar
|
my $sleep = ::shell_quote_scalar
|
||||||
('$|=1;while(1){sleep 1;print "foo\n"}');
|
('$|=1;while(1){sleep 1;print "foo\n"}');
|
||||||
my @master = ($ENV{'PARALLEL_SSH'}, "-tt", "-MTS",
|
my @master = ($opt::ssh, "-tt", "-MTS",
|
||||||
$control_path, $serverlogin, "perl", "-e",
|
$control_path, $serverlogin, "perl", "-e",
|
||||||
$sleep);
|
$sleep);
|
||||||
exec(@master);
|
exec(@master);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$sshcmd = $ENV{'PARALLEL_SSH'}; $serverlogin = $self->{'string'};
|
$sshcmd = $opt::ssh; $serverlogin = $self->{'string'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->{'sshcommand'} = $sshcmd;
|
$self->{'sshcommand'} = $sshcmd;
|
||||||
|
|
|
@ -1679,6 +1679,13 @@ Do not use the first line of input (used by GNU B<parallel> itself
|
||||||
when called with B<--shebang>).
|
when called with B<--shebang>).
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ssh> I<sshcommand> (alpha testing)
|
||||||
|
|
||||||
|
GNU B<parallel> defaults to using B<ssh> for remote access. This can
|
||||||
|
be overridden with B<--ssh>. It can also be set on a per server
|
||||||
|
basis (see B<--sshlogin>).
|
||||||
|
|
||||||
|
|
||||||
=item B<--sshdelay> I<secs>
|
=item B<--sshdelay> I<secs>
|
||||||
|
|
||||||
Delay starting next ssh by I<secs> seconds. GNU B<parallel> will pause
|
Delay starting next ssh by I<secs> seconds. GNU B<parallel> will pause
|
||||||
|
@ -3442,8 +3449,9 @@ $SHELL. If undefined use:
|
||||||
=item $PARALLEL_SSH (alpha testing)
|
=item $PARALLEL_SSH (alpha testing)
|
||||||
|
|
||||||
GNU B<parallel> defaults to using B<ssh> for remote access. This can
|
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
|
be overridden with $PARALLEL_SSH, which again can be overridden with
|
||||||
basis (see B<--sshlogin>).
|
B<--ssh>. It can also be set on a per server basis (see
|
||||||
|
B<--sshlogin>).
|
||||||
|
|
||||||
|
|
||||||
=item $PARALLEL_SEQ
|
=item $PARALLEL_SEQ
|
||||||
|
|
|
@ -66,6 +66,11 @@ echo '### use function as $PARALLEL_SSH'
|
||||||
export -f foossh;
|
export -f foossh;
|
||||||
PARALLEL_SSH=foossh parallel -S 1/lo echo ::: 'Run through FOOSSH?'
|
PARALLEL_SSH=foossh parallel -S 1/lo echo ::: 'Run through FOOSSH?'
|
||||||
|
|
||||||
|
echo '### use --ssh'
|
||||||
|
barssh() { echo "BARSSH" >&2; ssh "$@"; };
|
||||||
|
export -f barssh;
|
||||||
|
parallel --ssh barssh -S 1/lo echo ::: 'Run through BARSSH?'
|
||||||
|
|
||||||
echo '### test filename :'
|
echo '### test filename :'
|
||||||
echo content-of-: > :;
|
echo content-of-: > :;
|
||||||
echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}';
|
echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}';
|
||||||
|
|
|
@ -89,6 +89,11 @@ 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?'
|
foossh() { echo "FOOSSH" >&2; ssh "$@"; }; export -f foossh; PARALLEL_SSH=foossh parallel -S 1/lo echo ::: 'Run through FOOSSH?'
|
||||||
Run through FOOSSH?
|
Run through FOOSSH?
|
||||||
FOOSSH
|
FOOSSH
|
||||||
|
echo '### use --ssh'
|
||||||
|
### use --ssh
|
||||||
|
barssh() { echo "BARSSH" >&2; ssh "$@"; }; export -f barssh; parallel --ssh barssh -S 1/lo echo ::: 'Run through BARSSH?'
|
||||||
|
Run through BARSSH?
|
||||||
|
BARSSH
|
||||||
echo '### test filename :'
|
echo '### test filename :'
|
||||||
### test filename :
|
### test filename :
|
||||||
echo content-of-: > :; echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}'; cat :.:; rm : :.:
|
echo content-of-: > :; echo : | parallel -j1 --trc {}.{.} -S parallel@lo '(echo remote-{}.{.};cat {}) > {}.{.}'; cat :.:; rm : :.:
|
||||||
|
|
Loading…
Reference in a new issue