os.popen results differ when run in browser and DOS level

campbeld2 at my-deja.com campbeld2 at my-deja.com
Fri Sep 17 10:20:37 EDT 1999


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.




More information about the Python-list mailing list