Recursive search for string in file with Loop condition

Hi,

Need some help...

I want to execute sequence commands, like below

test1.sh
test2.sh
...etc

test1.sh file will generate log file, we need to search for 'complete' string on test1.sh file, once that condition success and then it should go to test2.sh file, each .sh scripts will take longer time, so that i want to put condition there that string "complete" should get in the log, then pass to next script.

Note: I tried with && and ;, but it doesn't work in my case as log has to generate and wait for some time. i dont know why its not wrking, so i thought to go for loop condition on log file, based on that it should go sequential.

Some one help on this how to get this.

Thanks

Your situation is a bit strange, but cannot be improved without knowing more about the test1.sh.
Here is a proposal for a strange solution on a strange problem:

test1.sh &
tail -f logfile_from_test1.sh | awk '/complete/ {exit}'
test2.sh &
tail -f logfile_from_test2.sh | awk '/complete/ {exit}'
test3.sh
...
1 Like

Will test1.sh stop/exit after writing "complete" or will it continue to exist? Do you have access to the scripts so you can modify them?

I just had a thought.

Although the previous *.sh technically exits when the newer running *.sh starts and the previous *.sh opens a file but fails to close it correctly will the garbage collection clear up the memory loss or will this become a memory leak?

Again just a thought...

test1.sh script will take longer time and sometimes its not coming out to proceed next script, so once "complete" script found in the log of test1, it should go to test2.sh. I have full access & can modify...but only thing is that its not working.

If you don't like MadeInGermany's proposal, here's two thoughts you may want to consider:
1) split test1.sh in at least two parts - one that does the task you wait for (e.g. write "complete") , and the other to do the rest.
2) have test1.sh write a file, or better, a named pipe when it completes the task you wait for.