I'm currently having a major issue with a python script. The script runs arbitrary commands through a handler to convert incorrect error reporting into correct error reporting.
The issue I'm having is getting the script to work correctly on windows with a command that contains ampersands in it's path. I've attempted quoting the command, escaping the ampersand with ^ and neither works. I'm now out of ideas. Any suggestions?
To clarify from current responses:
- I am using the subprocess module
- I am passing the command line + arguments in as a list
- The issue is with the path to the command itself, not any of the arguments
- I've tried quoting the command. It causes a '[Error 123] The filename, directory name, or volume label syntax is incorrect' error
- I'm using no shell argument (so shell=false)
- In case it matters, I'm grabbing a pipe to stderr for processing it, but ignoring stdout and stdin
- It is only for use on Windows currently, and works as expected in all other cases that I've tested so far.
The command that is failing is:
p = subprocess.Popen(prog, stderr = subprocess.PIPE, bufsize=-1)
when the first element of the list 'prog' contains any ampersands. Quoting this first string does not work.