3 # SPDX-FileCopyrightText: 2021 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
5 # SPDX-License-Identifier: GPL-3.0-or-later
8 myscript
=$
(cat <<'_EOF'
10 parallel --embed | tac | perl -pe '
11 /^parallel/ and not $seen++ and s{^}{
13 parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
14 env_parallel echo ::: env_parallel_OK
15 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
17 parallel echo ::: parallel_OK
18 PATH=/usr/sbin:/usr/bin:/sbin:/bin
19 # Do not look for parallel in /usr/local/bin
20 #. \`which env_parallel.ash\`
22 ' | tac > parallel-embed
23 chmod +x parallel-embed
28 ssh ash@lo
"$myscript"
32 myscript
=$
(cat <<'_EOF'
34 parallel --embed | tac | perl -pe '
35 /^parallel/ and not $seen++ and s{^}{
37 parset a echo ::: ParsetOK ParsetOK ParsetOK
38 env_parallel echo ::: env_parallel_OK
39 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
41 parallel echo ::: parallel_OK
42 PATH=/usr/sbin:/usr/bin:/sbin:/bin
43 # Do not look for parallel in /usr/local/bin
44 #. \`which env_parallel.bash\`
46 ' | tac > parallel-embed
47 chmod +x parallel-embed
52 ssh bash@lo
"$myscript"
64 myscript
=$
(cat <<'_EOF'
66 parallel --embed | tac | perl -pe '
67 /^parallel/ and not $seen++ and s{^}{
69 parset a echo ::: ParsetOK ParsetOK ParsetOK
70 env_parallel echo ::: env_parallel_OK
71 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
73 parallel echo ::: parallel_OK
74 PATH=/usr/sbin:/usr/bin:/sbin:/bin
75 # Do not look for parallel in /usr/local/bin
76 #. \`which env_parallel.ksh\`
78 ' | tac > parallel-embed
79 chmod +x parallel-embed
84 ssh ksh@lo
"$myscript"
88 myscript
=$
(cat <<'_EOF'
90 parallel --embed | tac | perl -pe '
91 /^parallel/ and not $seen++ and s{^}{
93 parset a,b,c echo ::: ParsetOK ParsetOK ParsetOK
94 env_parallel echo ::: env_parallel_OK
95 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
97 parallel echo ::: parallel_OK
98 PATH=/usr/sbin:/usr/bin:/sbin:/bin
99 # Do not look for parallel in /usr/local/bin
100 #. \`which env_parallel.sh\`
102 ' | tac > parallel-embed
103 chmod +x parallel-embed
108 ssh sh@lo
"$myscript"
116 myscript
=$
(cat <<'_EOF'
118 parallel --embed | tac | perl -pe '
119 /^parallel/ and not $seen++ and s{^}{
121 parset a echo ::: ParsetOK ParsetOK ParsetOK
122 env_parallel echo ::: env_parallel_OK
123 env_parallel --env myvar echo {} --env \\\$myvar ::: env_parallel
125 parallel echo ::: parallel_OK
126 PATH=/usr/sbin:/usr/bin:/sbin:/bin
127 # Do not look for parallel in /usr/local/bin
129 ' | tac > parallel-embed
130 chmod +x parallel-embed
135 ssh zsh@lo
"$myscript" 2>&1 |
139 par_propagate_env
() {
140 echo '### bug #41805: Idea: propagate --env for parallel --number-of-cores'
142 FOO
=test_zsh parallel
--env FOO
,HOME
-S zsh@lo
-N0 env
::: "" |
sort|
egrep 'FOO|^HOME'
143 echo '** test_zsh_filter'
144 FOO
=test_zsh_filter parallel
--filter-hosts --env FOO
,HOME
-S zsh@lo
-N0 env
::: "" |
sort|
egrep 'FOO|^HOME'
146 FOO
=test_csh parallel
--env FOO
,HOME
-S csh@lo
-N0 env
::: "" |
sort|
egrep 'FOO|^HOME'
147 echo '** test_csh_filter'
148 FOO
=test_csh_filter parallel
--filter-hosts --env FOO
,HOME
-S csh@lo
-N0 env
::: "" |
sort|
egrep 'FOO|^HOME'
149 echo '** bug #41805 done'
152 par_env_parallel_big_env
() {
153 echo '### bug #54128: command too long when exporting big env'
154 .
`which env_parallel.bash`
155 a
=`rand | perl -pe 's/\0//g'| head -c 70000`
156 env_parallel
-Slo echo should not
::: fail
2>&1
157 a
=`rand | perl -pe 's/\0//g'| head -c 80000`
158 env_parallel
-Slo echo should
::: fail
2>/dev
/null ||
echo OK
161 par_no_route_to_host
() {
162 echo '### no route to host with | and -j0 causes inf loop'
163 # Broken in parallel-20121122 .. parallel-20181022
164 # parallel-20181022 -j0 -S 185.75.195.218 echo ::: {1..11}
166 seq 11 | stdout parallel
-j0 -S $1 echo
168 export -f via_parallel
176 ip
='$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256)).$(($RANDOM%256))'
177 seq 10000 | parallel
-N0 echo $ip
180 # See if the hosts fail fast
182 stdout parallel
--timeout 2 -j5 ssh -o PasswordAuthentication
=no
{} echo |
183 perl
-ne 's/ssh:.* host (\d+\.\d+\.\d+\.\d+) .* No route .*/$1/ and print; $|=1'
187 # Cache a list of hosts that fail fast with 'No route'
188 # Filter the list 5 times to make sure to get good hosts
190 export -f filterhosts
192 findhosts | filterhosts | filterhosts | filterhosts |
193 filterhosts | filterhosts | head > /tmp/filtered.$$
194 mv /tmp/filtered.$$ /tmp/filtered.hosts
198 # We just need one of each to complete
199 stdout parallel
--halt now
,done=1 -j0 raw
:::: /tmp
/filtered.hosts
200 stdout parallel
--halt now
,done=1 -j0 via_parallel
:::: /tmp
/filtered.hosts
201 ) | perl
-pe 's/(\d+\.\d+\.\d+\.\d+)/i.p.n.r/' | puniq
204 par_PARALLEL_SSHLOGIN_SSHHOST
() {
205 echo '### bug #56554: Introduce $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST'
206 (echo lo
; echo zsh@lo
; echo /usr
/bin
/ssh csh@lo
; echo 1/sh@lo
;
207 echo 1//usr
/bin
/ssh tcsh@lo
) |
208 parallel
-k --tag --nonall -S - 'whoami;echo $PARALLEL_SSHLOGIN $PARALLEL_SSHHOST' |
212 export -f $
(compgen
-A function |
grep par_
)
213 #compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
214 #compgen -A function | grep par_ | sort |
215 compgen
-A function |
grep par_ | LANG
=C
sort -ri |
216 # parallel --joblog /tmp/jl-`basename $0` --delay $D -j$P --tag -k '{} 2>&1'
217 parallel
--joblog /tmp
/jl-
`basename $0` --delay 0.1 -j200% --tag -k '{} 2>&1' |
218 perl
-pe 's/line \d\d\d+:/line XXX:/' |
219 perl
-pe 's/\[\d\d\d+\]:/[XXX]:/'