parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help running an example (Calling Bash functions) from the manual


From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]
Subject: Re: Help running an example (Calling Bash functions) from the manual
Date: Fri, 23 May 2014 07:40:34 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

All,

Answering my own question here, thanks to the fine folks of Stack Overflow:

http://stackoverflow.com/questions/23814360/gnu-parallel-and-bash-functions-how-to-run-the-simple-example-from-the-manual

The issue was that I use tcsh as my login shell, thus $SHELL points to it, not bash. Thus parallel wanted to invoke tcsh as my shell when it did its work, even though I was calling it from a bash script.

Now, as the answer-er stated in that SO thread, this isn't very prominent in the manual. I was wondering if there would ever be a way to add an option to parallel? Say, if executing from a whatever-shell script you used whatever-shell to execute parallel? Or, perhaps, add an environment variable that parallel could see? I can't see how to add it to $PARALLEL, but maybe add a new $PARALLEL_SHELL?

Matt

On 05/22/2014 02:41 PM, Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] wrote:
Parallel List,

I'm a newbie to GNU parallel, but I decided today to try and parallelize
a Bash script I have but I just kept getting stymied. So, I thought I'd
just try the example from the manual:

http://www.gnu.org/software/parallel/man.html#example__calling_bash_functions


However, I can't seem to run that! To wit I placed that example in a
file called "tpar.bash" and just tried to run it, but it doesn't work:

(231) $ parallel --version
GNU parallel 20140522
Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014 Ole Tange and
Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
GNU parallel comes with no warranty.

Web site: http://www.gnu.org/software/parallel

When using programs that use GNU Parallel to process data for
publication please cite:

O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.

(232) $ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

(233) $ cat tpar.bash
#!/bin/bash

doit() {
  echo Doing it for $1
  sleep 2
  echo Done with $1
}
export -f doit
parallel doit ::: 1 2 3
doubleit() {
  echo Doing it for $1 $2
  sleep 2
  echo Done with $1 $2
}
export -f doubleit
parallel doubleit ::: 1 2 3 ::: a b

(234) $ bash tpar.bash
doit: Command not found.
doit: Command not found.
doit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.

Now, from the look of the bash output, parallel seems to be doing its
job, right? So I'm guessing that makes this a Bash issue and not a
parallel issue?

I thought I'd ask here first since it was in the parallel manual. But
I'll gladly ask this instead on the Bash list if you think that would be
better.

Matt



--
Matt Thompson          SSAI, Sr Software Test Engr
NASA GSFC, Global Modeling and Assimilation Office
Code 610.1, 8800 Greenbelt Rd, Greenbelt, MD 20771
Phone: 301-614-6712              Fax: 301-614-6246



reply via email to

[Prev in Thread] Current Thread [Next in Thread]