Using "subprocess" without lists. . .?
Peter Otten
__peter__ at web.de
Sun May 13 13:46:29 EDT 2007
Michael Williams wrote:
> I've recently seen the "subprocess" module and am rather confused by
> it's requirements. Is it not possible to execute an entire string
> without having to break them up into a list of arguments? For
> instance, I'd much rather do the following:
>
>
> subprocess.call("ls -al | grep -i test")
Try
subprocess.call("ls -al | grep -i test", shell=True)
>
>
> . . .than to have to:
>
>
> list = ["ls", "-a", "-l" ] . . . . . . and so on and so forth.
> subprocess.call(list. . .)
which avoids a lot of problems with shell quoting.
Peter
More information about the Python-list
mailing list