using grep in a while loop

Hello everybody,

I have been searching it, but it seems I am unable to find the correct information, that s why I am asking you guys, hoping somebody get an idea.
Here is my problem :

I want a script to loop until a string is identified in a log file.
Here is the script :

 
#!/bin/sh
##Wait for database script to finish
rc=2
while [ ! $rc -eq 0 ]
do
grep "BUILD SUCCESSFUL" /berp001_i1/AMH/database/logs/database_2012-01-31_15-11-45.log
rc="$?"
done

Do you have an idea where is the problem ?

Again thank you and sorry if the answer were outthere.

guyiom

Hi guyiom,

I don't understand. What do you want to achieve? Loop until a string in the log file and what?

Regards,
Birei

Hello Birai,

Thank you for your interest for my problem.
I want my script to hang in loop until it finds the string in the log, and then the script should continue until its end.
Is it clearer ?

guyiom

while ! grep "BUILD SUCCESSFUL" /berp001_i1/AMH/database/logs/database_2012-01-31_15-11-45.log > /dev/null
do
        sleep 1
done

Hello Corona688.

Thank you for your answer, but when I execute the script, I get this error :

"
[amh@berp001 database]$ ./test.sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory
"

Any idea what I am doing wrong ?

Thank you

guyiom

You are editing scripts in Microsoft Notepad. This fills your scripts with useless carriage returns, which UNIX will consider part of the filename or command.

Edit them in UNIX instead.