os.popen results diff when executed in browser vs DOS
Cliff Daniel
cdaniel at Level3.net
Fri Sep 24 14:34:31 EDT 1999
I'd try a couple things just to see if it worked.
1. use sys.stdout.write('blah blah<br>\n')
or print 'a <pre> tag' [this should be unbuffered.]
campbeld2 at my-deja.com writes:
> I'm resubmitting this question on the off chance someone can help me,
> please. I suspect it is to do with nested stdout results, but I'm at a
> loss here.
> Thanks
> Dyan
>
>
> In article <7rtin6$9oa$1 at nnrp1.deja.com>,
> campbeld2 at my-deja.com wrote:
> > This sample program illustrates my dilema.
> >
> > I am trying to execute a command ( could be
> > any command ) within Python and capture the
> > output. It works fine when I run it at command
> > level, however when I invoke the script in the
> > browser the code does not return any values from
> > the os.popen(...)readlines. I tried try: and
> > except: but nothing is trapped.
> >
> > Any ideas?
> >
> > ------
> >
> > """
> > test.py :
> > returns correct results at command level (great)
> > returns nothing through Browser !!!
> > """
> > import os
> >
> > print 'Content-Type: text/html\n\n',
> > for line in os.popen( 'cd','r' ).readlines():
> > print '<P>...within for loop \n\n'
> > cd = line
> >
> > print '<P>cd = ', cd, '\n\n'
> >
> > #end of test.py
> >
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.
> >
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
> --
> http://www.python.org/mailman/listinfo/python-list
--
Cliff Daniel
Level 3 Communications
More information about the Python-list
mailing list