[Tutor] Using command line tool with python script

Rüdiger Wolf rudiger.wolf at throughputfocus.com
Mon Oct 5 21:56:59 CEST 2009


On Mon, 05 Oct 2009 12:59 -0400, "Kent Johnson" <kent37 at tds.net> wrote:
> On Mon, Oct 5, 2009 at 10:22 AM, Oleg Oltar <oltarasenko at gmail.com>
> wrote:
> 
> > os.popen4("application -parameter1 -file temp.txt")
> >
> > I wonder if that possible to execute this script (called application)
> > without writing the file with initial data to the hard disk?
> 
> If "application" can take its input from stdin then you can use the
> subprocess module to launch it and pipe data to it. If "application"
> requires a file for input then I think you have to write a file.

Matt Harrison have some notes and a video of a talk about good python
scripting practices.
He describes some patterns that enable you to write python scripts that
can be chained together as they process data from one and send it to the
next.

See the following links for more info.
http://panela.blog-city.com/oscon_scripting_with_python_handout.htm
http://en.oreilly.com/oscon2009/public/schedule/detail/8317

He created a tool called poachplate so that it is easier to create these
kind of scripts.
http://pypi.python.org/pypi?%3Aaction=search&term=poachplate

Regards
Rudiger


More information about the Tutor mailing list