0

I'm trying to start/stop the app server using os.system command in my python script. I have to wait until the server start/stop. I'm trying to loop through log file using grep command below. But I'm getting invalid syntax on the search string on the double quote(single quote). If i run the grep command directly it works fine. Please let me know what would be the issue or any alternative way. (I'm using Redhat enterprise linux )

while ! grep -m1 'Server started' < /apps/logs/messages.log; do
       sleep 1
done

In my python job when i tried to run the below code, I'm getting "invalid syntax" on the search string double quote (tried single quote as well). Both failing with invalid syntax error. Can you please let let me know what would be the issue. (Redhat enterprise linux).

3
  • 3
    Please edit your question and show us the code. How did you run this in python? We can't help you debug if you don't show us what you did. More importantly, why in the world would you start a shell loop in python instead of having python do the looping for you?
    – terdon
    Jul 16 '20 at 9:32
  • This question is related to unix.stackexchange.com/q/323577/377345
    – AdminBee
    Jul 16 '20 at 9:34
  • You're also going to go wrong when the server starts and stops multiple times. Read man pgrep, or is there a socket the server creates, or a port it opens (read man lsof).
    – waltinator
    Jul 16 '20 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.