1

I want to run a shell script behind, which does a specific job, simultaneously I will wait for the user's input to end the job. How can I achieve this? Here is my example code:

from subprocess import call

cmd = "internals/applog.sh "
call([cmd])

raw_input("Press Y when you are done: ")

The above code first executes the call statement and only after the app log.sh ends then the following message comes.

Any help in this? how can I make it, when user enters y, the call statement to be aborted?

2 Answers 2

2
pid = Popen(["internals/applog.sh",])

while True:
    answer = raw_input("Press Y when you are done: ")
    if answer == 'Y':
        pid.kill()
        break
Sign up to request clarification or add additional context in comments.

Comments

1

call() waits for the command to be completed, I think you'd want to use Popen instead:

from subprocess import Popen

Popen(["internals/applog.sh"])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.