I have a Python script (2.7) which I use to invoke an external process.Till recently it worked fine.
But now when I run it I see it doesn't pass over process arguments.I have also debugged the invoked process and it receives only the single argument (the path of the process executable).
p = subprocess.Popen(["./myapp","-p","s"],shell=True)
p.communicate()
Execution of the above code passes only "myapp" as the command argument.Why could that happen?
When using
shell=True
, just pass a string (not a list);Update
Always prefer;
shell=False
(the default) toshell=True
and pass an array of strings; andI.e.;
If you're just interested in the
stdout
(and not thestderr
), prefer this to the above solution (it's safer and shorter):Don't use
shell=True
: