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

Amir Mistric amir.mistric at usa.net
Mon Aug 21 12:11:53 EDT 2000


Thank You for the prompt responses....

Amir



<yanivk at my-deja.com> wrote in message news:8nrb8f$aql$1 at nnrp1.deja.com...
> 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