Hi,
Can anyone please say what is wrong with this code:
require "cgi"
index = CGI.new("html3")
if (! FileTest.exists?("config.ini")) then
index.out{"Cannot find config.ini file"}
exit
end
print index.a("http://www.example.com"){ "Example" }
What is wrong with the last line. When I execute this through the web
browser I can see in the error logs:
[Tue Nov 01 23:22:03 2005] [error] [client 10.38.0.15] Premature end of
script headers: index.cgi
Thanks
Depp
Hi,
Can anyone please say what is wrong with this code:
require "cgi"
index = CGI.new("html3")
if (! FileTest.exists?("config.ini")) then
index.out{"Cannot find config.ini file"}
exit
end
print index.a("http://www.example.com"){ "Example" }
What is wrong with the last line. When I execute this through the web
browser I can see in the error logs:
[Tue Nov 01 23:22:03 2005] [error] [client 10.38.0.15] Premature end of
script headers: index.cgi
Thanks
Depp
Assuming that your config.ini exists we can shorten the example to
require "cgi"
index = CGI.new("html3")
print index.a("http://www.example.com"){ "Example" }
now if you execute this via the commandline you see this output
$ ruby test.cgi
(offline mode: enter name=value pairs on standard input)^D
<A HREF="http://www.example.com">Example</A>bschroed@oerfi:~/svn/projekte/ruby-things$
where one can see that the header lines are missing. Change the above to:
···
On 02/11/05, lahirister@gmail.com <lahirister@gmail.com> wrote:
-----
#!/usr/bin/ruby
require "cgi"
index = CGI.new("html3")
index.out do
index.a("http://www.example.com"){ "Example" }
end
------
and the output becomes
-------
Content-Type: text/html
Content-Length: 44
<A HREF="http://www.example.com">Example</A>
-------
This should work as a cgi script.
hope to help,
Brian
--
http://ruby.brian-schroeder.de/
Stringed instrument chords: http://chordlist.brian-schroeder.de/