execute commands and return output

Leif K-Brooks eurleif at ecritters.biz
Sat Sep 10 13:30:14 CEST 2005

billiejoex wrote:
> Thank you for your help but I'm searching a different way.
> Moreover it doesn't work always (for exaple: try a 'dir' command).
> Because of I'm implementing a remote shell  the 
> [[os.popen('command').read()]] rapresents the best for me because it can 
> also accepts arguments direclty  (for example: 
> os.popen('netstat -a -n -o').read() and this is a great advantage.

If you really need shell evaluation, try subprocess.Popen('foo',
shell=True) instead.

More information about the Python-list mailing list