capturing output from os.system() in Windows?

David gabnash at hotmail.com
Wed Apr 23 04:03:33 EDT 2003


Being a complete novice at python, I thought I'd try a simple script
to run a NET VIEW (which runs in a DOS box) command under Windows and
then manipulate the resulting data.

The first problem I have encountered is how to capture the output from
the 'NET VIEW' command.

os.system('NET VIEW') returns 0 under windows, although the DOS box
pops up and the NET VIEW executes correctly.

Is there some other command I should be using instead? I guess an
alternative might be to run the 'NET VIEW' under dos and redirect the
output into a python script using a BAT file?

Any ideas?




More information about the Python-list mailing list