os.popen results diff when executed in browser vs DOS

campbeld2 at my-deja.com campbeld2 at my-deja.com
Fri Sep 24 12:24:29 EDT 1999


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.




More information about the Python-list mailing list