From: "Brian Schröder" Date: 2005-11-02T16:37:10+09:00 Subject: Re: How to use htmlextension of cgi class? On 02/11/05, lahirister@gmail.com wrote: > 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 Examplebschroed@oerfi:~/svn/projekte/ruby-things$ where one can see that the header lines are missing. Change the above to: ----- #!/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 Example ------- This should work as a cgi script. hope to help, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/