I am running an external program using pipes in python and it works fine. However I would like to pass two arguments to this external program.
Could anyone help me with that?
Thanks!
I am running an external program using pipes in python and it works fine. However I would like to pass two arguments to this external program.
Could anyone help me with that?
Thanks!
from subprocess import Popen, PIPE
p = Popen(['external-program', 'arg1', 'arg2'],
stdin=PIPE, stdout=PIPE, stderr=PIPE)
if you mean piping the out into or out of the Python script, or
from subprocess import Popen, PIPE
p = Popen('external-program arg1 arg2 | external2'], shell=True)
if you mean piping output between external programs.
See the subprocess docs. Post your code if you want a different type of solution.
shell=True is when you are on windows and you need to call commands that are cooked into cmd.exe'cat file1 | grep "glob"' would work without shell=True? What would interpret the pipe?