Python or 4NT? With a question or two about popen()

Mark McEahern marklists at
Mon Sep 13 01:59:16 CEST 2004

On Sun, 2004-09-12 at 18:52, Robin Siebler wrote:
> And how, exactly, do I *use* popen4()?

import os
command = 'ls -al nonexistent'
fin, fout = os.popen4(command)
# I never futz with stdin.
output =
exitCode = fout.close()
if exitCode:
    print 'Error running %(command)s:\n%(output)s' % locals()
    print 'Success running %(command)s:\n%(output)s' % locals()

This may have minor syntactical errors or typos--since I'm not verifying
it by running it.  But mostly, the above pattern should work.


// m

More information about the Python-list mailing list