Using "subprocess" without lists. . .?

Michael Williams mwilliams at mgreg.com
Sun May 13 12:17:24 EDT 2007


Hi All,

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")


. . .than to have to:


list = ["ls", "-a", "-l" ]  . . . . . . and so on and so forth.
subprocess.call(list. . .)


What is the best way to go about executing a massively complex single  
line command?


Thanks,
Michael



More information about the Python-list mailing list