0

I have an application which is modularised like this:

`APP
    PART1
       part1.sh
    PART2
       part2.o
    PART3
       part3.o`

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:

OUTPUT1="output1.txt"
OUTPUT2="output2.txt"
./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?

5
  • What were you expecting < $0 to accomplish? Do you really want part1.sh to process the contents of the file run.sh? Commented Jun 14, 2016 at 1:16
  • @John1024 I see. I have fixed that part, but it still causes the same behavior. I want to trigger part1.sh from run.sh (the other way round). Commented Jun 14, 2016 at 1:22
  • What do you expect ./PART1/part1.sh $0 to accomplish? Please explain what you think $0 means. Commented Jun 14, 2016 at 1:29
  • Check this one stackoverflow.com/a/8352939/524743 Commented Jun 14, 2016 at 1:31
  • @John1024 I thought i was referring to input.txt with $0 Commented Jun 14, 2016 at 1:32

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Sweet. Got it. That was super dumb from my part. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.