Command shell access within Python

Pierre Rouleau pieroul at attglobal.net
Sun Nov 4 18:12:23 EST 2001


Janko Hauser wrote:

>
> A better way is to use the commands module. It wraps os.popen and I'm
> not sure if this also didn't open a shell beforehand.
>

Do you know if the commands module is supported under Win32 (NT) by python 2.1?
I tried it and it does not seem to work:

>>> import commands
>>> dir(commands)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'getoutput', 'getstatus', 'getstatusoutput', 'mk2arg', 'mkarg']
>>> (exitstatus, outtext) = commands.getstatusoutput('ls')
>>> exitstatus
1
>>> outtext
'The name specified is not recognized as an\ninternal or external command, operable program or batch file.'


Pierre




More information about the Python-list mailing list