subprocess and & (ampersand)
steven.bethard at gmail.com
Wed Jan 23 06:53:20 CET 2008
I'm having trouble using the subprocess module on Windows when my
command line includes special characters like "&" (ampersand)::
>>> command = 'lynx.bat', '-dump', 'http://www.example.com/?x=1&y=2'
>>> kwargs = dict(stdin=subprocess.PIPE,
>>> proc = subprocess.Popen(command, **kwargs)
"'y' is not recognized as an internal or external command,\r\noperable
program or batch file.\r\n"
As you can see, Windows is interpreting that "&" as separating two
commands, instead of being part of the single argument as I intend it to
be above. Is there any workaround for this? How do I get "&" treated
like a regular character using the subprocess module?
More information about the Python-list