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

yanivk at my-deja.com yanivk at my-deja.com
Mon Aug 21 09:36:17 EDT 2000


In article <Ft9o5.1806$p36.418637 at news2.mia>,
  "Amir Mistric" <amir.mistric at usa.net> wrote:
> 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......

I'm not sure this will help you, but you might want to try (on Unix): stdout,
stdin, stderr = os.popen3("program.exe") then you need to bind these to a
callback that will be called whenever any kind of input arrives.

>
> 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????
>
Not that I know of
> Thanks
> Amir
>
>
Yaniv


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list