2018-01-25 02:48:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
par_ash_embed() {
|
|
|
|
myscript=$(cat <<'_EOF'
|
|
|
|
echo '--embed'
|
|
|
|
parallel --embed | tac | perl -pe '
|
|
|
|
/^parallel/ and not $seen++ and s{^}{
|
|
|
|
echo \$b
|
|
|
|
parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
|
|
|
|
env_parallel echo ::: env_parallel_OK
|
2018-03-06 00:32:41 +00:00
|
|
|
env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
|
|
|
|
myvar=OK
|
2018-01-25 02:48:16 +00:00
|
|
|
parallel echo ::: parallel_OK
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# Do not look for parallel in /usr/local/bin
|
2018-05-08 21:16:48 +00:00
|
|
|
#. \`which env_parallel.ash\`
|
2018-01-25 02:48:16 +00:00
|
|
|
}
|
|
|
|
' | tac > parallel-embed
|
|
|
|
chmod +x parallel-embed
|
|
|
|
./parallel-embed
|
2018-03-06 00:32:41 +00:00
|
|
|
rm parallel-embed
|
2018-01-25 02:48:16 +00:00
|
|
|
_EOF
|
|
|
|
)
|
|
|
|
ssh ash@lo "$myscript"
|
|
|
|
}
|
|
|
|
|
|
|
|
par_bash_embed() {
|
|
|
|
myscript=$(cat <<'_EOF'
|
|
|
|
echo '--embed'
|
|
|
|
parallel --embed | tac | perl -pe '
|
|
|
|
/^parallel/ and not $seen++ and s{^}{
|
|
|
|
echo \${a[1]}
|
|
|
|
parset a echo ::: ParsetOK ParsetOK ParsetOK
|
|
|
|
env_parallel echo ::: env_parallel_OK
|
2018-03-06 00:32:41 +00:00
|
|
|
env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
|
|
|
|
myvar=OK
|
2018-01-25 02:48:16 +00:00
|
|
|
parallel echo ::: parallel_OK
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# Do not look for parallel in /usr/local/bin
|
2018-05-08 21:16:48 +00:00
|
|
|
#. \`which env_parallel.bash\`
|
2018-01-25 02:48:16 +00:00
|
|
|
}
|
|
|
|
' | tac > parallel-embed
|
|
|
|
chmod +x parallel-embed
|
|
|
|
./parallel-embed
|
|
|
|
rm parallel-embed
|
|
|
|
_EOF
|
|
|
|
)
|
|
|
|
ssh bash@lo "$myscript"
|
|
|
|
}
|
|
|
|
|
|
|
|
par_csh_embed() {
|
|
|
|
echo Not implemented
|
|
|
|
}
|
|
|
|
|
|
|
|
par_fish_embed() {
|
|
|
|
echo Not implemented
|
|
|
|
}
|
|
|
|
|
|
|
|
par_ksh_embed() {
|
|
|
|
myscript=$(cat <<'_EOF'
|
|
|
|
echo '--embed'
|
|
|
|
parallel --embed | tac | perl -pe '
|
|
|
|
/^parallel/ and not $seen++ and s{^}{
|
|
|
|
echo \${a[1]}
|
|
|
|
parset a echo ::: ParsetOK ParsetOK ParsetOK
|
|
|
|
env_parallel echo ::: env_parallel_OK
|
2018-03-06 00:32:41 +00:00
|
|
|
env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
|
|
|
|
myvar=OK
|
2018-01-25 02:48:16 +00:00
|
|
|
parallel echo ::: parallel_OK
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# Do not look for parallel in /usr/local/bin
|
2018-05-08 21:16:48 +00:00
|
|
|
#. \`which env_parallel.ksh\`
|
2018-01-25 02:48:16 +00:00
|
|
|
}
|
|
|
|
' | tac > parallel-embed
|
|
|
|
chmod +x parallel-embed
|
|
|
|
./parallel-embed
|
2018-05-08 21:16:48 +00:00
|
|
|
rm parallel-embed
|
2018-01-25 02:48:16 +00:00
|
|
|
_EOF
|
|
|
|
)
|
|
|
|
ssh ksh@lo "$myscript"
|
|
|
|
}
|
|
|
|
|
|
|
|
par_sh_embed() {
|
|
|
|
myscript=$(cat <<'_EOF'
|
|
|
|
echo '--embed'
|
|
|
|
parallel --embed | tac | perl -pe '
|
|
|
|
/^parallel/ and not $seen++ and s{^}{
|
|
|
|
echo \$b
|
|
|
|
parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
|
|
|
|
env_parallel echo ::: env_parallel_OK
|
2018-03-06 00:32:41 +00:00
|
|
|
env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
|
|
|
|
myvar=OK
|
2018-01-25 02:48:16 +00:00
|
|
|
parallel echo ::: parallel_OK
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# Do not look for parallel in /usr/local/bin
|
2018-05-08 21:16:48 +00:00
|
|
|
#. \`which env_parallel.sh\`
|
2018-01-25 02:48:16 +00:00
|
|
|
}
|
|
|
|
' | tac > parallel-embed
|
|
|
|
chmod +x parallel-embed
|
|
|
|
./parallel-embed
|
2018-05-08 21:16:48 +00:00
|
|
|
rm parallel-embed
|
2018-01-25 02:48:16 +00:00
|
|
|
_EOF
|
|
|
|
)
|
|
|
|
ssh sh@lo "$myscript"
|
|
|
|
}
|
|
|
|
|
|
|
|
par_tcsh_embed() {
|
|
|
|
echo Not implemented
|
|
|
|
}
|
|
|
|
|
|
|
|
par_zsh_embed() {
|
|
|
|
myscript=$(cat <<'_EOF'
|
|
|
|
echo '--embed'
|
|
|
|
parallel --embed | tac | perl -pe '
|
|
|
|
/^parallel/ and not $seen++ and s{^}{
|
|
|
|
echo \${a[1]}
|
|
|
|
parset a echo ::: ParsetOK ParsetOK ParsetOK
|
|
|
|
env_parallel echo ::: env_parallel_OK
|
2018-03-06 00:32:41 +00:00
|
|
|
env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
|
|
|
|
myvar=OK
|
2018-01-25 02:48:16 +00:00
|
|
|
parallel echo ::: parallel_OK
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
# Do not look for parallel in /usr/local/bin
|
|
|
|
}
|
|
|
|
' | tac > parallel-embed
|
|
|
|
chmod +x parallel-embed
|
|
|
|
./parallel-embed
|
|
|
|
rm parallel-embed
|
|
|
|
_EOF
|
|
|
|
)
|
2019-09-22 05:30:08 +00:00
|
|
|
ssh zsh@lo "$myscript" 2>&1 |
|
|
|
|
grep -v .zshenv:.:1
|
2018-01-25 02:48:16 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 22:15:14 +00:00
|
|
|
par_propagate_env() {
|
|
|
|
echo '### bug #41805: Idea: propagate --env for parallel --number-of-cores'
|
|
|
|
echo '** test_zsh'
|
|
|
|
FOO=test_zsh parallel --env FOO,HOME -S zsh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
|
|
|
|
echo '** test_zsh_filter'
|
|
|
|
FOO=test_zsh_filter parallel --filter-hosts --env FOO,HOME -S zsh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
|
|
|
|
echo '** test_csh'
|
|
|
|
FOO=test_csh parallel --env FOO,HOME -S csh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
|
|
|
|
echo '** test_csh_filter'
|
|
|
|
FOO=test_csh_filter parallel --filter-hosts --env FOO,HOME -S csh@lo -N0 env ::: "" |sort|egrep 'FOO|^HOME'
|
|
|
|
echo '** bug #41805 done'
|
|
|
|
}
|
|
|
|
|
|
|
|
par_env_parallel_big_env() {
|
|
|
|
echo '### bug #54128: command too long when exporting big env'
|
|
|
|
. `which env_parallel.bash`
|
2018-12-29 20:04:58 +00:00
|
|
|
a=`rand | perl -pe 's/\0//g'| head -c 70000`
|
2018-09-20 22:15:14 +00:00
|
|
|
env_parallel -Slo echo should not ::: fail 2>&1
|
2018-10-22 22:46:38 +00:00
|
|
|
a=`rand | perl -pe 's/\0//g'| head -c 80000`
|
2018-09-22 21:09:30 +00:00
|
|
|
env_parallel -Slo echo should ::: fail 2>/dev/null || echo OK
|
2018-09-20 22:15:14 +00:00
|
|
|
}
|
|
|
|
|
2018-11-25 18:06:06 +00:00
|
|
|
par_no_route_to_host() {
|
|
|
|
echo '### no route to host with | and -j0 causes inf loop'
|
2019-01-01 13:34:04 +00:00
|
|
|
# Broken in parallel-20121122 .. parallel-20181022
|
|
|
|
# parallel-20181022 -j0 -S 185.75.195.218 echo ::: {1..11}
|
2018-11-25 18:06:06 +00:00
|
|
|
via_parallel() {
|
2018-12-29 20:04:58 +00:00
|
|
|
seq 11 | stdout parallel -j0 -S $1 echo
|
2018-11-25 18:06:06 +00:00
|
|
|
}
|
|
|
|
export -f via_parallel
|
|
|
|
raw() {
|
2018-12-29 20:04:58 +00:00
|
|
|
stdout ssh $1 echo
|
2018-11-25 18:06:06 +00:00
|
|
|
}
|
|
|
|
export -f raw
|
|
|
|
|
2019-07-31 20:38:30 +00:00
|
|
|
# Random hosts
|
2018-12-29 20:04:58 +00:00
|
|
|
findhosts() {
|
|
|
|
ip='$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256))'
|
2019-07-31 20:38:30 +00:00
|
|
|
seq 10000 | parallel -N0 echo $ip
|
2018-12-29 20:04:58 +00:00
|
|
|
}
|
|
|
|
|
2019-07-31 20:38:30 +00:00
|
|
|
# See if the hosts fail fast
|
2018-12-29 20:04:58 +00:00
|
|
|
filterhosts() {
|
2019-01-29 05:58:12 +00:00
|
|
|
stdout parallel --timeout 2 -j5 ssh -o PasswordAuthentication=no {} echo |
|
2018-12-29 20:04:58 +00:00
|
|
|
perl -ne 's/ssh:.* host (\d+\.\d+\.\d+\.\d+) .* No route .*/$1/ and print; $|=1'
|
|
|
|
}
|
|
|
|
|
|
|
|
(
|
|
|
|
# Cache a list of hosts that fail fast with 'No route'
|
2019-10-21 19:18:32 +00:00
|
|
|
# Filter the list 5 times to make sure to get good hosts
|
|
|
|
export -f findhosts
|
|
|
|
export -f filterhosts
|
|
|
|
nice bash -c '
|
|
|
|
findhosts | filterhosts | filterhosts | filterhosts |
|
|
|
|
filterhosts | filterhosts | head > /tmp/filtered.$$
|
|
|
|
mv /tmp/filtered.$$ /tmp/filtered.hosts
|
|
|
|
'
|
2018-12-29 20:04:58 +00:00
|
|
|
) &
|
|
|
|
(
|
2019-07-31 20:38:30 +00:00
|
|
|
# We just need one of each to complete
|
2018-12-29 20:04:58 +00:00
|
|
|
stdout parallel --halt now,done=1 -j0 raw :::: /tmp/filtered.hosts
|
|
|
|
stdout parallel --halt now,done=1 -j0 via_parallel :::: /tmp/filtered.hosts
|
|
|
|
) | perl -pe 's/(\d+\.\d+\.\d+\.\d+)/i.p.n.r/' | puniq
|
2018-11-25 18:06:06 +00:00
|
|
|
}
|
|
|
|
|
2020-05-23 16:44:42 +00:00
|
|
|
par_PARALLEL_SSHLOGIN_SSHHOST() {
|
|
|
|
echo '### bug #56554: Introduce $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST'
|
2019-06-27 13:49:49 +00:00
|
|
|
(echo lo; echo zsh@lo; echo /usr/bin/ssh csh@lo; echo 1/sh@lo;
|
|
|
|
echo 1//usr/bin/ssh tcsh@lo) |
|
2020-05-23 16:44:42 +00:00
|
|
|
parallel -k --tag --nonall -S - 'whoami;echo $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST' |
|
2019-09-22 05:30:08 +00:00
|
|
|
LANG=C sort
|
2019-06-27 13:49:49 +00:00
|
|
|
}
|
|
|
|
|
2018-01-25 02:48:16 +00:00
|
|
|
export -f $(compgen -A function | grep par_)
|
|
|
|
#compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
|
|
|
|
#compgen -A function | grep par_ | sort |
|
2019-09-22 05:30:08 +00:00
|
|
|
compgen -A function | grep par_ | LANG=C sort -ri |
|
2018-01-25 02:48:16 +00:00
|
|
|
# parallel --joblog /tmp/jl-`basename $0` --delay $D -j$P --tag -k '{} 2>&1'
|
2018-11-25 18:06:06 +00:00
|
|
|
parallel --joblog /tmp/jl-`basename $0` --delay 0.1 -j200% --tag -k '{} 2>&1' |
|
2018-05-08 21:16:48 +00:00
|
|
|
perl -pe 's/line \d\d\d+:/line XXX:/' |
|
|
|
|
perl -pe 's/\[\d\d\d+\]:/[XXX]:/'
|