Problem using commands.getoutput()

Jerry Hill malaclypse2 at gmail.com
Tue Dec 8 14:44:44 EST 2009


On Tue, Dec 8, 2009 at 2:31 PM, J <dreadpiratejeff at gmail.com> wrote:
>
> So what's the point of the commands module, or is that one that only
> works in Linux, and not Windows?

At the very top of http://docs.python.org/library/commands.html it
says "Platforms: Unix", so yes, it's Unix-only.

> I can do what I want, I think, by
> using os.popen(), but I wanted to know if there was a better way of
> doing it.

Also at the top of that same bit of documentation is this: "The
subprocess module provides more powerful facilities for spawning new
processes and retrieving their results. Using the subprocess module is
preferable to using the commands module."

I would start with http://docs.python.org/library/subprocess.html and
http://www.doughellmann.com/PyMOTW/subprocess/ for more information
about the subprocess module and how it works.

-- 
Jerry



More information about the Python-list mailing list