I used to be able to do a subprocess.call(["command","-option value -option value"])
and it would work there was a change to the command to work properly with things in quotes, but now I have to change my subprocess call command to look like this:
subprocess.call(["command","-option","value","-option","value"])
is there something I can do to get it to work the other way again in python?
the os.system("command -option value -option value")
works the same as it did before.
Avoid shell=True
if you can -- it's a security risk. For this purpose, shlex.split suffices:
import subprocess
import shlex
subprocess.call(shlex.split("command -option value -option value"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With