In article 
<[email protected]>,
 Chris Weisiger <[email protected]> wrote:
> I want to sanitize some strings (e.g. escape apostrophes, spaces, etc.)
> before passing them to the commandline via subprocess. Unfortunately I can't
> seem to find any built-in function to do this. Am I really going to have to
> write up my own sanitizer? Not that it'd be much effort, but I'd much rather
> use an official function than risk forgetting something.

The subprocess doc show how to use shlex to parse a shell-like command 
string.  I'm not sure I understand your use case but is there a reason 
you can't use 'shell=False' and set up the arguments yourself, thus 
avoiding the need for escapes?  Even if you really need to have a shell 
execute the string, you should be able to set up the arguments and call 
the shell directly.  

http://docs.python.org/library/subprocess.html

-- 
 Ned Deily,
 [email protected]

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to