os.popen results differ run by browser vs DOS prompt
campbeld2 at my-deja.com
campbeld2 at my-deja.com
Fri Sep 17 10:20:40 EDT 1999
#!/bin/env python
"""
test.py
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 '...within for loop \n\n'
cd = line
print '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