[Tutor] nested os.popen()
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Tue May 3 23:50:29 CEST 2005
On Tue, 3 May 2005, Jules Bravo wrote:
> I'm trying to create a program that can recreate the unix pipe. So
> basically I need to be able to take something like "ls *.py | du | wc"
> and be able to run it just like unix would, doing a wordcount of the du
> of all files that end with .py. My question is how would I do this
> without being able to create pipes that have both read and write
> capabilities.
Hi Jules,
You may want to look at the 'subprocess' module:
http://www.python.org/doc/lib/module-subprocess.html
The documentation in:
http://www.python.org/doc/lib/node237.html
shows how to implement pipelines. The example is slightly cut down, since
you'll probably need to add something like:
######
from subprocess import Popen, PIPE
######
to make it work. But, otherwise, it should be self-contained.
If you have more questions, please feel free to ask. Good luck!
More information about the Tutor
mailing list