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:
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
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