Raena Steeves
Raena Steeves

Reputation: 3

exiting a running command in python

I'm new to python. I'm writing a script that calls a command line tool and displays the output from the command on the screen. The issue is that after the command runs it doesn't exit on it's own, it requires manual typing of ctrl-c to stop and continue on with the rest of the python script. Does anyone know how I could get it to stop on it's own and continue on with the rest of the script?

cmd ='./ppshelper -sms "15062929382" warning'
os.system(cmd)
print "SMS sent"

"SMS sent" is not printed until the user presses ctrl-c

Thanks

Upvotes: 0

Views: 103

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174708

Use Popen

from subprocess import Popen
p = Popen(['/full/path/to/ppshelper', '-sms', '15062929382','warning'])
p.terminate()

Upvotes: 1

Related Questions