I am currently having a problem with a python script. The script executes arbitrary commands through a handler to convert the invalid error message to the correct error message.
The problem I ran into is getting the script to work correctly with windows using a command containing ampersands in this path. I tried to quote the command avoiding the ampersand with ^, and none of them work. I have no ideas now. Any suggestions?
To clarify current answers:
- I use the subprocess module
- I pass the command line + arguments as a list
- The problem is with the path of the command itself, not with the arguments
- I tried to quote the command. It causes an error
[Error 123] The filename, directory name, or volume label syntax is incorrect - I do not use shell argument (s
shell=false) - In case that matters, I grab the tube for stderr to handle it, but ignore stdout and stdin
- It is used only for Windows and works as expected in all other cases that I have tested so far.
- Team Failure:
p = subprocess.Popen (prog, stderr = subprocess.PIPE, bufsize = -1)
when the first element of the prog list contains any ampersands. Quoting this first line does not work.
source
share