how to get command output using python

kyosohma at gmail.com kyosohma at gmail.com
Thu Aug 9 19:51:50 CEST 2007


On Aug 9, 12:01 pm, Arnau Sanchez <ar... at ehas.org> wrote:
> Steven Harms escribió:
>
> > In python it is quite easy:
>
> > import commands
> > status, output = commands.getstatusoutput("my command")
>
> Uhm, this module has a big issue:
>
> (http://docs.python.org/lib/module-commands.html)
> ----
> 8.17 commands -- Utilities for running commands
>
> Availability: Unix.
> ----
>
> Any non cross-platform module should be avoided unless absolutely necessary.
>
> Subprocess is the right module to use.
>
> arnau

You forgot to mention that subprocess replaces commands, so in effect,
commands is deprecated anyway.

Mike




More information about the Python-list mailing list