[Tutor] CGI error

Darren Williams Darren at newspyn.com
Fri Jul 13 19:13:14 CEST 2007


 Hi all  

I have a Windows hosting account with lunarpages.com and am having a bit of trouble with CGI. I have enabled both CGI and Python in the control panel and made sure the permissions for all my CGI scripts are set to both readable and executable for all users but I keep getting the same 'The specified CGI application misbehaved by not returning a complete set of HTTP headers' error. 

The script that i'm trying to execute (example_7.1.py) - 


Code: [Download]
  1.. #!/usr/bin/python
  2.. 
  3.. # Import the CGI module
  4.. import cgi
  5.. 
  6.. # Required header that tells the browser how to render the HTML.
  7.. print "Content-Type: text/html\n\n"
  8.. 
  9.. # Define function to generate HTML form.
  10.. def generate_form():
  11..     print "<HTML>\n"
  12..     print "<HEAD>\n"
  13..     print "\t<TITLE>Info Form</TITLE>\n"
  14..     print "</HEAD>\n"
  15..     print "<BODY BGCOLOR = white>\n"
  16..     print "\t<H3>Please, enter your name and age.</H3>\n"
  17..     print "\t<TABLE BORDER = 0>\n"
  18..     print "\t\t<FORM METHOD = post ACTION = \
  19..     \"example_7.1.cgi\">\n"
  20..     print "\t\t<TR><TH>Name:</TH><TD><INPUT type = text \
  21..     name = \"name\"></TD><TR>\n"
  22..     print "\t\t<TR><TH>Age:</TH><TD><INPUT type = text name = \
  23..     \"age\"></TD></TR>\n"
  24..     print "\t</TABLE>\n"
  25..     print "\t<INPUT TYPE = hidden NAME = \"action\" VALUE = \
  26..     \"display\">\n"
  27..     print "\t<INPUT TYPE = submit VALUE = \"Enter\">\n"
  28..     print "\t</FORM>\n"
  29..     print "</BODY>\n"
  30..     print "</HTML>\n"
  31.. 
  32..     # Define function display data.
  33..     def display_data(name, age):
  34..     print "<HTML>\n"
  35..     print "<HEAD>\n"
  36..     print "\t<TITLE>Info Form</TITLE>\n"
  37..     print "</HEAD>\n"
  38..     print "<BODY BGCOLOR = white>\n"
  39..     print name, ", you are", age, "years old."
  40..     print "</BODY>\n"
  41..     print "</HTML>\n"
  42.. 
  43..     # Define main function.
  44..     def main():
  45..     form = cgi.FieldStorage()
  46..     if (form.has_key("action") and form.has_key("name") \
  47..     and form.has_key("age")):
  48..              if (form["action"].value == "display"):
  49..                 display_data(form["name"].value, form["age"].value)
  50..     else:
  51..              generate_form()
  52.. 
  53..     # Call main function.
  54..     main()
  55.. 


And the server log - 

#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 12:11:28 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 12:11:27 W3SVC12090 ARCTURUS 209.200.254.99 GET /Index.aspx - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 200 0 0 995 403 593 
2007-07-13 12:11:27 W3SVC12090 ARCTURUS 209.200.254.99 GET /Images/ComingSoon.png - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - http://newspyn.com/ newspyn.com 404 0 2 1819 374 93 
2007-07-13 12:11:30 W3SVC12090 ARCTURUS 209.200.254.99 GET /Images/development.bmp - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - http://newspyn.com/ newspyn.com 200 0 0 1000335 375 2984 
2007-07-13 12:11:30 W3SVC12090 ARCTURUS 209.200.254.99 GET /favicon.ico - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 404 0 2 1819 334 93 
2007-07-13 12:11:51 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_1.1.cgi - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 404 0 3 1819 426 93 
2007-07-13 12:12:05 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 404 0 2 1819 410 109 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 13:03:04 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 13:03:04 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_1.1.cgi - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 404 0 3 1819 426 218 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 13:30:37 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 13:30:37 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_1.1.cgi - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 426 421 
2007-07-13 13:36:22 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.cgi - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 426 281 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 14:33:25 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 14:33:25 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.cgi - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 452 406 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 15:31:18 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 15:31:18 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.py - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 425 6546 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 16:00:27 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 16:00:26 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.py - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 451 421 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 16:34:43 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken 
2007-07-13 16:34:43 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.py - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 451 406 
2007-07-13 16:37:07 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin/example_7.1.py - 80 - 74.14.92.189 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4 - - newspyn.com 502 2 0 417 451 343 

Thanks in advance for any help 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070713/bea40533/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 174 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20070713/bea40533/attachment-0001.gif 


More information about the Tutor mailing list