0

There are a lot of similar questions, but I cannot find an example of what I am looking for, nor in the Bash scripting guides (I'm sure it's there but its a big book...)

What I want is this:

I have a file I call by: ./runMe.sh, whose contents are this:

callMaxima() {
maxima -b "$1"
}
callSINGULAR() {
/opt/local/bin/Singular -b "$2"
}
callMaxima $1;
callSINGULAR $2;

I want Maxima to do some stuff, dictated by the first argument passed in the terminal, e.g. ./runMe MaximaFile SINGULARFile, and which will generate a text file, Maxima.OUT.

I then want, after the file above (Maxima.OUT) is written, to start SINGULAR in batch mode (also), with the file passed to it by the second argument, e.g. SINGULARFile. It will read in data from Maxima.OUT and do some stuff.

The problem:

The sccript runs Maxima fine, writes the file, exits and enters SINGULAR. But apparently the file argument, e.g. SINGULARFile, is not being opened. I can easily start SINGULAR from the terminal and automatically execute/open the file with

/opt/local/bin/SINGULAR -b SINGULARFile

but it isn't working in the runMe.sh. Since the programs seem very very similar, I'm assuming my runMe.sh isn't working right...

1 Answer 1

2

This function should looks like:

callSINGULAR() {
/opt/local/bin/Singular -b "$1"
}

Because the parameter is first, provided to function

2
  • Oh! I was thinking of parameter counting like in C. Thanks :)
    – nate
    Commented May 3, 2015 at 18:36
  • The parameters are local and they do not traverse subshell invocations. You are welcome :) Commented May 3, 2015 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .