capturing the output of external commands
fperez528 at yahoo.com
Mon Jul 26 05:16:41 CEST 2004
Avi Kak wrote:
> Is there a Python function in any of the
> standard-distribution modules that does
> what the backticks do in Perl?
> I want to run an external command and I'd
> like its output to be captured directly
> in my Python script in the form of a string
In : import commands
In : commands.getoutput?
Base Class: <type 'function'>
String Form: <function getoutput at 0x874a094>
Return output (stdout or stderr) of executing cmd in a shell.
You can get fancy using popen, and capture separately stdout/err, but for a
simple capture getoutput should do.
More information about the Python-list