Fixed bug #47695: How to set $PATH on remote?

This commit is contained in:
Ole Tange 2016-05-29 17:18:53 +02:00
parent 51f212e548
commit ff27e601bf
4 changed files with 89 additions and 13 deletions

View file

@ -258,6 +258,10 @@ for Big Data Applications https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumb
* <<link No citation: Next-generation TCP for ns-3 simulator http://www.sciencedirect.com/science/article/pii/S1569190X15300939>>
* GNU Parallel is a fantastic utility https://www.dray.be/parallel/
* Tools of the trade http://onox.com.br/2015/05/tools-of-the-trade/#more-198
* Bug fixes and man page updates.
GNU Parallel - For people who live life in the parallel lane.

View file

@ -2944,7 +2944,7 @@ sub setup_basefile {
::wait_and_exit(255);
}
if(not $workdir) {
my $dummycmdline = CommandLine->new(1,"true",0,0,0,0,0,{},{},{});
my $dummycmdline = CommandLine->new(1,["true"],{},0,0,[],[],{},{},{});
my $dummyjob = Job->new($dummycmdline);
$workdir = $dummyjob->workdir();
}
@ -3037,7 +3037,6 @@ sub parse_host_filtering {
# \%echo = echo received from {host}
# \@down_hosts = list of hosts with no answer
my (%ncores, %ncpus, %time_to_login, %maxlen, %echo, @down_hosts);
for (@_) {
::debug("init",$_);
chomp;
@ -3052,7 +3051,8 @@ sub parse_host_filtering {
next;
}
# Get server from: eval true server\;
$col[8] =~ /eval true..([^;]+).;/ or ::die_bug("col8 does not contain host: $col[8]");
$col[8] =~ /eval true..([^;]+).;/ or
::die_bug("col8 does not contain host: $col[8]");
my $host = $1;
$host =~ tr/\\//d;
$Global::host{$host} or next;
@ -3122,20 +3122,32 @@ sub parallelized_host_filtering {
# * hostname \t number of cpus
# * hostname \t max-line-length-allowed
# * hostname \t empty
sub sshwrapped {
# Wrap with ssh and --env
my $sshlogin = shift;
my $command = shift;
my $commandline = CommandLine->new(1,[$command],{},0,0,[],[],{},{},{});
my $job = Job->new($commandline);
$job->set_sshlogin($sshlogin);
$job->wrapped();
return($job->{'wrapped'});
}
my(@cores, @cpus, @maxline, @echo);
my $envvar = ::shell_quote_scalar($Global::envvar);
while (my ($host, $sshlogin) = each %Global::host) {
if($host eq ":") { next }
# The 'true' is used to get the $host out later
push(@cores, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --number-of-cores")."\n\0");
push(@cpus, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --number-of-cpus")."\n\0");
push(@maxline, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --max-line-length-allowed")."\n\0");
# 'echo' is used to get the fastest possible ssh login time
my $sshcmd = "true $host; exec " .$sshlogin->sshcommand()." ".
$sshlogin->serverlogin();
push(@cores, $host."\t".$sshcmd." -- ".$envvar.
" parallel --number-of-cores\n\0");
push(@cpus, $host."\t".$sshcmd." -- ".$envvar.
" parallel --number-of-cpus\n\0");
push(@maxline, $host."\t".$sshcmd." -- ".$envvar.
" parallel --max-line-length-allowed\n\0");
# 'echo' is used to get the best possible value for an ssh login time
push(@echo, $host."\t".$sshcmd." -- echo\n\0");
}
my ($fh, $tmpfile) = ::tmpfile(SUFFIX => ".ssh");
@ -3147,11 +3159,11 @@ sub parallelized_host_filtering {
# will make it less likely to overload the ssh daemon.
# --retries 3: If the ssh daemon it overloaded, try 3 times
# -s 16000: Half of the max line on UnixWare
# TODO sh -c wrapper to work in csh
my $unlinkcmd = $Global::debug ? "true" : "rm $tmpfile";
my $cmd = "($unlinkcmd; cat -) < $tmpfile | ".
"$0 -j0 --timeout 10 -s 16000 --joblog - --plain --delay 0.1 --retries 3 ".
"--tag --tagstring {1} -0 --colsep '\t' -k eval {2} 2>/dev/null";
"$0 -j0 --timeout 10 --joblog - --plain --delay 0.1 --retries 3 ".
"--tag --tagstring '{1}' -0 --colsep '\t' -k eval '{2}' ";
$cmd = $Global::shell." -c ".::shell_quote_scalar($cmd);
::debug("init", $cmd, "\n");
my @out;
my $prepend = "";

View file

@ -84,3 +84,35 @@ echo '### exported function to csh but with PARALLEL_SHELL=bash'
PARALLEL_SHELL=bash parallel --env doit -S csh@lo doit ::: OK
EOF
echo 'bug #47695: How to set $PATH on remote?'
rm -rf /tmp/parallel
cp /usr/local/bin/parallel /tmp
cat <<'_EOS' | stdout ssh nopathbash@lo -T
echo BASH Path before: $PATH with no parallel
parallel echo ::: 1
echo '^^^^^^^^ Not found is OK'
# Exporting a big variable should not fail
export A="`seq 1000`"
PATH=$PATH:/tmp
. /usr/local/bin/env_parallel.bash
# --filter to see if $PATH with parallel is transferred
env_parallel --filter --env A,PATH -Slo echo '$PATH' ::: OK
_EOS
echo
cat <<'_EOS' | stdout ssh nopathcsh@lo -T
echo CSH Path before: $PATH with no parallel
which parallel >& /dev/stdout
echo '^^^^^^^^ Not found is OK'
alias parallel=/tmp/parallel
# Exporting a big variable should not fail
setenv A "`seq 1000`"
setenv PATH ${PATH}:/tmp
cp /usr/local/bin/env_parallel.csh /tmp
# --filter to see if $PATH with parallel is transferred
env_parallel --filter --env A,PATH -Slo echo '$PATH' ::: OK
_EOS

View file

@ -122,3 +122,31 @@ echo '### exported function to csh but with PARALLEL_SHELL=bash'
doit() { echo "$1"; }; export -f doit; stdout parallel --env doit -S csh@lo doit ::: not_OK; PARALLEL_SHELL=bash parallel --env doit -S csh@lo doit ::: OK
CSH/TCSH DO NOT SUPPORT newlines IN VARIABLES/FUNCTIONS. Unset doit
OK
bug #47695: How to set $PATH on remote?
Welcome to Linux Mint 17 Qiana (GNU/Linux 3.16.0-31-lowlatency x86_64)
Welcome to Linux Mint
* Documentation: http://www.linuxmint.com
195 packages can be updated.
0 updates are security updates.
BASH Path before: /bin:/usr/bin with no parallel
-bash: line 2: parallel: command not found
^^^^^^^^ Not found is OK
/bin:/usr/bin:/tmp OK
Welcome to Linux Mint 17 Qiana (GNU/Linux 3.16.0-31-lowlatency x86_64)
Welcome to Linux Mint
* Documentation: http://www.linuxmint.com
195 packages can be updated.
0 updates are security updates.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
CSH Path before: /bin:/usr/bin with no parallel
parallel: Command not found.
^^^^^^^^ Not found is OK
/bin:/usr/bin:/tmp OK