Sanitising arguments to shell commands (was: Waiting for a subprocess to exit)

Chris Rebert clp2 at
Fri Aug 21 11:19:13 CEST 2009

On Fri, Aug 21, 2009 at 2:08 AM, Ben Finney<ben+python at> wrote:
> How can I take a string that is intended to be part of a command line,
> representing multiple arguments and the shell's own escape characters as
> in the above example, and end up with a sane command argument list for
> ‘subprocess.Popen’?

module shlex — Simple lexical analysis
New in version 1.5.2.
"The shlex class makes it easy to write lexical analyzers for simple
syntaxes resembling that of the Unix shell."


More information about the Python-list mailing list