[Tutor] CGI-version not working while similar command-line script is fine

Gerhard Venter s.venter at ntlworld.com
Sun Sep 5 18:08:27 CEST 2004


Hi Kent

Thanks - my code is below.  It should output a plain text version of any 
website

G

Kent Johnson wrote:

> This should work. My guess is you have an error in your script, maybe 
> a problem with quoting or string substitution. Can you show us the 
> script that is having trouble?
>
import cgi, os
import cgitb; cgitb.enable()

form = cgi.FieldStorage()
website = form["websitename"].value
command = 'lynx --dump ' + website
k=os.popen(command, 'r')

print 'Content-type: text/plain'
print

#print command  (this shows the right thing- for example lynx --dump 
www.google.com)
for line in k.readlines():
      print(line)


More information about the Tutor mailing list