Why can we not use Popen
to run a batch file?
>>> p = Popen(["filename"], shell=True, stdout = PIPE)
This is working well, but according to the documentation we should not use shell = True
for "running a batch file or console-based executable".
Why can't we use shell = True
when it runs a batch file? Why should it only be used for building in cmd?
Calling
subprocess.Popen()
with theshell
parameter set toTrue
in production is a generally bad idea. One of the dangers include shell injection vulnerabilities, as quoted by the Python 3 docs:Source: https://docs.python.org/3.6/library/subprocess.html