ikis ikis - 1 year ago 37
Bash Question

How trigger multiple dependent programs using shell?

I have an application which is modularised like this:


Input file for part1.o generates a output file that is again input file for part2.o, which generates another file, which is input for part3.o and finally the output for overall app.

I'm intending to have a run.sh file that should take the first input file for the sub-application (part1) and so and forth trigger the rest of the sub-applications and store the last output in a file name, mentioned with command. Something like this:

run.sh input.txt output.txt

Currently my shell looks like this:

./PART1/part1.sh $0 > OUTPUT1 &&
./PART2/part2.o < OUTPUT1 > OUTPUT2 &&
./PART3/part3.o < OUTPUT2 > $1

Currently, if I run this code, I get the following output indefinitely long:

+ ./run.sh
+ ./run.sh
+ ./run.sh

Can anyone help me with this? What am I doing wrong?

Answer Source

You are using positional parameters incorrectly.

run.sh input.txt output.txt

will populate positional params with values given below

$0 = run.sh

$1 = input.txt

$2 = output.txt

More on positional params