print to stdout and to a log file.....

Amir Mistric amir.mistric at usa.net
Mon Aug 21 08:47:29 EDT 2000


Hi
If I have a command
os.system("program.exe %s %s" %(file1,file2))
how can I capture the output of this execution to both stdout and to a lets
say log file.....

I tried

log_detail = os.popen("program.exe %s %s" %(file1,file2))
LogFile.write("%s" % log_detail.read())

but this did not write output to neither stdout nor my log file......

Also another question I have is :
Is it possible to have one print statement that wil write to stdout and to a
file? For example:
print "---------------------------------------------------------"
LogFile.write("---------------------------------------------------------\n")

Can this be accomplished in some other fashion where only one line of code
can be written????

Thanks
Amir








More information about the Python-list mailing list