How to execute shell command in Python program?
Chris Narkiewicz
hello at ezaquarii.com
Sat Jul 20 10:39:58 EDT 2019
Madhavan Bomidi wrote:
> import subprocess
> subprocess.call(['./opac'],shell=True)
subprocess.call(['./opac', "my-input.inp"], shell=True)
The array takes command with a list of arguments. This
way you don't need to do space escaping and other
Jujitsu gimmicks.
If you want to feed the command from stdin, this becomes a bit
more complicated as you need to start a subprocess and use
PIPE to feed it.
Cheers,
Chris Narkiewicz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20190720/9156b259/attachment.sig>
More information about the Python-list
mailing list