Forum Moderators: coopster & phranque

Message Too Old, No Replies

Premature end of script errors

Trying to setup cgi for first time and getting script errors

         

direct_one

12:11 pm on Dec 12, 2003 (gmt 0)

10+ Year Member




I'm trying to get CGI scripts working and my hoster's tech guy just went home for the w.e.

When I run the script in the browser, I get appache logs that look like:

203.123.69.211 - - [12/Dec/2003:22:22:34 +1100] "GET /cgi-bin/test.cgi HTTP/1.0"
500 609 "-" "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; Alexa Toolbar)"

AND

[Fri Dec 12 22:22:34 2003] [error] [client 203.123.69.211] Premature end of script headers: /home/virtual/site186/fst/var/www/cgi-bin/test.cgi

Am I missing something really simple here

My script is dirt simple----
print "200 OK\n";

# Print an HTML response to the user
print "content-type: text/html\n\n";

print "<html>\n";

print "<HEAD>\n";
print "<TITLE>hello, world html </TITLE>\n";
print "<H2>Hello, World, in HTML </H2>\n";
print "</HEAD>\n";

print "<body>\n";
print "<h3>Your data has been sent.</h3>\n";
print "</body>\n";
print "</html>\n";

panoylis

12:21 pm on Dec 12, 2003 (gmt 0)

10+ Year Member



I don't see any content-type header...

print "content-type: text/html\n\n";

duh! .... ehmm ....

ok ... I will punish my self ... "learn to read, learn to read, .... "

have you the right perl path?

#!/usr/bin/perl

does your script generate an error, print to stdout and all that before the content-type header?

Try with the content-type header at the very beginning.. :-)

incywincy

12:48 pm on Dec 12, 2003 (gmt 0)

10+ Year Member



i think you're right,
print "200 OK\n";
occurs before
print "content-type: text/html\n\n";

try putting the print 200 stuff AFTER the content-type

direct_one

12:57 pm on Dec 12, 2003 (gmt 0)

10+ Year Member



OK,
I'm off and running now :)
I had attributes set to 777. Set them to 755 and off she goes! yippie

IanKelley

5:11 am on Dec 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There is no need to print the 200 code at all, the server will handle this.