From: Diego Guillen Date: 2009-03-14T21:11:56+09:00 Subject: Re: Windows cgihandler Error: Premature end of script headers Kevin Layman wrote: > Any suggestions at all on this would be greatly appreciated. Hi had the same problem recently in Windows (with Ruby 1.8.6-26), after my script was already working in Ubuntu Linux. I'm surprised that no one has provided an answer to this problem yet. There could be several factors involved: * your Windows security policies levels; * what program gets associated with the execution of cgi scripts. Doing a bit of debugging, I located the problem down to the last line on the file: c:\ruby\lib\ruby\1.8\webrick\httpservlet\cgi_runner.rb where is says: exec ENV["SCRIPT_FILENAME"] I replaced that line with the following code: # --- from here --- Ruby = File::join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name']) Ruby << ::Config::CONFIG['EXEEXT'] if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM exec "#{Ruby}", ENV["SCRIPT_FILENAME"] else exec ENV["SCRIPT_FILENAME"] end # --- to here --- This just builds a constant Ruby with the full path to "ruby.exe", and (if you're running on Windows) passes it as an extra first parameter "c:\ruby\bin\ruby.exe" , to the Kernel.exec() method. Save the file and restart the server. It worked for me. -- Posted via http://www.ruby-forum.com/.