Hi, Rubyists.
I’m just starting to play with cgi and forms. I have a simple script
which runs okay, except that the page changes to 500: Internal Server
Error, with the error message “Premature end of script headers” on
the script.
Search, this seems to be a permissioning problem. Permissions are 755.
Ideas?
Ruby 1.7.3 (mswin), Apache 2.0.43, Win2k.
cat lform.rb
require ‘cgi’
require ‘log4r’
add some basic logging
···
logger = Log4r::Logger.new(‘lform’)
Log4r::FileOutputter.new(‘logfile’,
:filename=>‘logs/lform.log’,
:trunc=>true,
:level=>Log4r::DEBUG)
logger.add(‘logfile’)
cgi
cgi = CGI.new
cgi.params.each { |key, val|
logger.debug “key=#{key} val=#{val}”
}
-mark.
if the cgi runs from the command line, but does not from the browser, chances
are that user nobody (or www or whatever) does not have permission to write
to the specified directory. two things which generally help me alot with
cgis are
-
get sudo su nobody permission - run all your scripts from the command line
as user nobody (or www, or whatever apache runs as)
-
when all else fails, make everything 777 (chmod -R 777) and run again, if
that works the problem IS a permissions one, track it down and gradually
shut permissions down untill it stops working - you found the problem
i KNOW many will freak out at that suggestion, like about half the
developers in our group, but i’ve solved at LEAST 50 or 60 bugs that way
in under a minute - in every case the developer just didn’t want to go 777
on principle, but there is no problem with this, IMHO, if it’s temporary.
-a
···
On Sat, 9 Nov 2002, Mark Probert wrote:
I’m just starting to play with cgi and forms. I have a simple script
which runs okay, except that the page changes to 500: Internal Server
Error, with the error message “Premature end of script headers” on
the script.
Search, this seems to be a permissioning problem. Permissions are 755.
Ideas?
–
====================================
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
Are you printing an http header?
eg:
puts “Content-type: text/html\n\n”
or, using the cgi object
cgi.out {
“this is some html text”
}
– Wes
···
----- Original Message -----
From: “Mark Probert” probertm@nortelnetworks.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, November 08, 2002 12:02 PM
Subject: Basic CGI question
Hi, Rubyists.
I’m just starting to play with cgi and forms. I have a simple script
which runs okay, except that the page changes to 500: Internal Server
Error, with the error message “Premature end of script headers” on
the script.
Search, this seems to be a permissioning problem. Permissions are 755.
Ideas?
Search, this seems to be a permissioning problem. Permissions are 755.
Ideas?
(I tried Ara’s idea of 777 and it doesn’t help… )
Are you printing an http header?
eg:
puts “Content-type: text/html\n\n”
No, I was just reading the cgi.params.
Do I need to write something as well?
-mark.
···
At 04:11 AM 11/9/2002 +0900, Weswrote:
Search, this seems to be a permissioning problem. Permissions are
Ideas?
(I tried Ara’s idea of 777 and it doesn’t help… )
Are you printing an http header?
eg:
puts “Content-type: text/html\n\n”
No, I was just reading the cgi.params.
Do I need to write something as well?
Yes, I believe that you do. I don’t think that you can post a form to a cgi
without returning something to the client, and anything that you do send
must start with the Content-type header.
– Wes
···
----- Original Message -----
From: “Mark Probert” probertm@nortelnetworks.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, November 08, 2002 3:10 PM
Subject: Re: Basic CGI question
At 04:11 AM 11/9/2002 +0900, Weswrote:
Hi, Wes.
No, I was just reading the cgi.params.
Do I need to write something as well?
Yes, I believe that you do. I don’t think that you can post a form to a cgi
without returning something to the client, and anything that you do send
must start with the Content-type header.
That worked. I included
cgi.out {
“this is some html text”
}
And everything worked.
Maybe something for the CGI for Beginners FAQ.
Thanks for your help.
-mark.
···
At 05:24 AM 11/9/2002 +0900, you wrote: