The best way to debug cgi is to tail the server log when you don't get 
commandline output. This will give you a clue to what is happening.. shoulld be 
something like /var/log/apache or something like that...
Eric....




wormwood_3 <[EMAIL PROTECTED]> wrote: Hello all,

I am working on a very simple CGI script. The site I want to use it on is a 
shared linux host, but I confirmed that .py files in the right dir with the 
right permissions and shebang execute just fine, Hello World sort of tests were 
successful.

So now something a little more involved:


#!/usr/bin/python2.4

import cgitb; cgitb.enable()

thefile = open("template.html", "r")
templatestuff = thefile.read()
thefile.close()
print "Content-Type: text/html"
if templatestuff:
    print "Found it"
title1 = "I am a title!"
body1 = "I am some hot content"
print templatestuff % (title1, body1)

"template.html" is in the same dir, and is simply:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>


  
 %s     
  
  
                %s
  


If I run this script without the 3 lines after the import line, it works fine 
(namely I get an error that templatestuff is not defined, as would be 
expected). With those lines however, I am getting a 500 Internal Server Error. 
Since I am not shown an error page with cgitb, this would likely mean a syntax 
error. However, if I run the script locally, it works just fine, printing out 
the HTML with variables filled in. Now for the odd part: If I change that open 
line to "thefile = open("asdas", "r")", I get "IOError: [Errno 2] No such file 
or directory: 'asdas'
". So it seems the script is finding the template file when I have it as above, 
but is throwing something when it tries to open it. I have confirmed the file 
has the right permissions, I have even tried it with all permissions set on 
that file.

I am just totally baffled why I cannot open any files from the script.

Any ideas?
-Sam





_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


       
---------------------------------
Catch up on fall's hot new shows on Yahoo! TV.  Watch previews, get listings, 
and more!
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to