Python Subprocess Issue With Ampersands
Solution 1:
Make sure you are using lists and no shell expansion:
subprocess.Popen(['command', 'argument1', 'argument2'], shell=False)
Solution 2:
A proper answer will need more information than that. What are you actually doing? How does it fail? Are you using the subprocess module? Are you passing a list of arguments and shell=False (or no shell argument) or are you actually invoking the shell?
Solution 3:
Try quoting the argument that contains the &
wget "http://foo.com/?bar=baz&baz=bar"
Is usually what has to be done in a Linux shell
Solution 4:
"escaping the ampersand with ^"
Are you sure ^
is an escape character to Windows? Shouldn't you use \
?
Solution 5:
To answer my own question:
Quoting the actual command when passing the parameters as a list doesn't work correctly (command is first item of list) so to solve the issue I turned the list into a space separated string and passed that into subprocess instead.
Better solutions still welcomed.
Post a Comment for "Python Subprocess Issue With Ampersands"