Python or 4NT? With a question or two about popen()
marklists at mceahern.com
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()?
command = 'ls -al nonexistent'
fin, fout = os.popen4(command)
# I never futz with stdin.
output = fout.read()
exitCode = fout.close()
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.
More information about the Python-list