A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/308671.html below:

execute commands and return output

execute commands and return output execute commands and return outputtiissa tiissa at nonfree.fr
Sat Sep 10 05:34:28 EDT 2005
billiejoex wrote:
> Hi all. I'm searching for a portable (working on *nix and win32) function 
> that executes a system command and encapsulate its output into a string.
> Searching for the web I found this:
> 
> os.popen('command').read()
> 
> It is perfect but when che command return an error the funciotn returns an 
> empy string.
> Does it is possible to return stdout and stderr too?

You may want to look at the subprocess [1] module and its Popen class [2].

[1] http://python.org/doc/2.4.1/lib/module-subprocess.html
[2] http://python.org/doc/2.4.1/lib/node234.html


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4