views:

34

answers:

1

I have a bash script with a code like this:

echo "EXECUTING TASK 1"
sort -r scripts/sh/test-list | while read fn; do    
    sh -vx scripts/sh/test-web-task.sh "$fn"
done

echo "EXECUTING TASK 2"
sort -r scripts/sh/test-unit-list | while read fn; do   
    sh -vx scripts/sh/test-unit-task.sh "$fn"
done

In test-web-task and test-unit-task I have some calls to grails to run some tests and then do some packaging stuff. Something like this:

grails test-app $1
mv results backup/$1

In files scripts/sh/test-unit-list and scripts/sh/test-list I have a list of tests to run. Something like this:

Person
Book

The first loop breaks without running all the lines of the file scripts/sh/test-list and then it starts to run the second loop.

As you can see I have added -vx to sh to see what may be the problem. But I can't find what I doing wrong.

I think maybe something in scripts/sh/test-list is crashing, and breaking the loop. If this is the case I want to know what is crashing, and I want the loop to keep going without break.

Can you give me any pointer?

A: 
sh -vx scripts/sh/test-web-task.sh "$fn" < /dev/null

The second script probably is stealing the stdout and stdin of the original script. Let me know if this fixes it

mezzie
Sorry, I don't understand. Do you suggest to replace sh -vx scripts/sh/test-web-task.sh "$fn" with sh -vx scripts/sh/test-web-task.sh "$fn" < /dev/null ?
damian
the second script you are running from your main script is stealing the stdin and stdout. Since the second script finishes fine after its first run, it will exit the main script also therefore not showing any errors. I will try to find the site I read this about and add another comment.
mezzie
It works perfectly. I had replaced as I asked in the other comment and works. Thanks
damian