Use grep result to execute next command

Hi I am trying to run 2 servers using a script one after the other.

I start the first one:

run.sh -c servername >> jboss_log.txt &

Then I have to wait until I see Started message in the log file before I launch the other server.

I can't use sleep because I am not sure how long it'll take for the server to startup. So I need something like

while (true) {
if [tail -f jboss_log.txt | grep Started ] //meaning when it was found
then 
   break
fi
}

start the next command

obviously this doesn't work,

any hint on how I could write something like this?

Thanks in advance

run.sh -c servername >> jboss_log.txt &
wait $!

Thanks for the reply,

however wait$! doesn't work because
run.sh -c servername >> jboss_log.txt &

is never terminated, never returns, it keeps writing to boss_log.txt forever. So my 2nd server doesn't start.

So far I have

      5 
      6 
      7 while [ 1 ]
      8 do
      9 
     10    myvar= fgrep -c 'Started in' jboss_log.txt
     11 
     12    echo $myvar
     13 
     14   if [ $myvar==1 ]
     15   then
     16       echo "JBoss was launched successfully"
     17         break
     18       fi
     19       sleep 1
     20     done

But the if statement is always true even thou line 12 prints 0.
Can anyone tell me why?

The standard idiom is:

while :

Or:

while true

Syntax error. There can be no space after the equals sign.

That will always be true as you are testing a non-empty string. There is no test operator in that statement.

And the test for numerical equality is -eq:

if [ $myvar -eq 1 ]

Thanks a lot for your help.

I fixed it :

while [ 1 ]
do
myvar=`fgrep -c 'Started in' jboss_log.txt`

if [ "$myvar" -eq "1" ]
then
   echo "JBoss was launched successfully"
   break
fi
  sleep 5

done