Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While loop condition 1

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
I'm stuck with the definition of the condition in a while loop. What I want to do is loop until a certain process has started. I can't easily test this directly because it requires restarting the machine so I'm testing by watching for any process which is owned by a certain user (so when I login as that user the process begins & because I'm trying to use negation the loop should terminate). This is my test code:

Code:
while [ ! "ps -ef | grep [x]x" ]
do
        sleep 1
        echo NOT YET
done

echo STARTED

xx is a user - when I login as xx I expect the condition to evaluate to false so it should fall out of the loop.

But this always seems to return TRUE (so it never loops). I don't know if my loop is wrong, my negation syntax is wrong or if I'm just barking up the wrong tree & should try a completely different approach. Either way I just can't figure it out.

Any suggestions gratefully received as usual.

Chris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top