[Tutor] How to run a system application and get the stdout in Python?

Alan Gauld alan.gauld at blueyonder.co.uk
Mon Nov 17 05:18:20 EST 2003


> I see a number of os module possibilities to run system commands.
> Here's what I'm trying to run:
>
> /usr/bin/htmldoc -t pdf --webpage
'http://127.0.0.1/draco/wiki.dsp/Lund?cmd=View&page=FrontPage&PDF=True
'
>
> What's the best way to run this and how do I grab the stdout of the
command?

The best way is to use the popen function. But make sure that your
script has the right permissions set etc and that you check for
errors carefully. Also be aware that you are opening up a potential
security hole in your system, so make sure that only the commands
you want can be executed!

Alan G




More information about the Tutor mailing list