On 29 Mar 2005 13:23:55 -0800, "Tian" <wa*********@gmail.com> wrote:
In Windows, I have been simply using os.system() to run command line
program in python. but there will be a black console window. How can I
run the program without invoking that window? i guess there are some
function with which I can redirect the output?
Instead of
os.system(cmdstring)
try using
the_output = os.popen(cmdstring).read()
to run the command and get the output. There are other variations
to capture stderr or combined output etc.
If you want to do popen(cmdstring) from a python program that does not _itself_
have a console window, look into running _that_ using the pythonw.exe (note "w")
interpreter instead of the python.exe interpreter, as others have mentioned.
Regards,
Bengt Richter