Webrick newbie question

Hi,

I am playing with Webrick that comes with the latest one-click installer on Windows XP (Home).

I cannot get the CGIHandler to work correctly. Here is the HTTPServer script:

···

#######################################
require 'webrick'
include WEBrick

def start_webrick(config = {})
  config.update(:Port => 8080)
  server = HTTPServer.new(config)
  yield server if block_given?
  server.mount("/docs", HTTPServlet::FileHandler, "C:/atest/webrick/htdocs" )
  server.mount("/cgi-bin", HTTPServlet::CGIHandler, "C:/atest/webrick/ruby/cgi")
  ['INT', 'TERM'].each {|signal|
    trap(signal) {server.shutdown}
  }
  server.start
end

start_webrick(:DocumentRoot => "C:/atest/webrick",:CGIInterpreter => "C:/ruby/bin/ruby.exe")

__END__

#######################################

If I create a simple helloworld.cgi script and save it under C:/atest/webrick/htdocs, then I can
run it using http://localhost:8080/docs/helloworld.cgi

But if I save the same script under C:/atest/webrick/ruby/cgi and invoke it as:
http://localhost:8080/cgi-bin/helloworld.cgi

I get "HTTP 500 - Internal server error" in the browser (I.E. 6.0 SP2) and the following messages
at the console:
------------------------------------
<previous messages sniped>

[2005-08-05 22:28:46] ERROR CGIHandler: C:/atest/webrick/ruby/cgi:
C:/ruby/bin/ruby.exe: Permission denied -- C:/atest/webrick/ruby/cgi (LoadError)
[2005-08-05 22:28:46] ERROR CGIHandler: C:/atest/webrick/ruby/cgi exit with 1
[2005-08-05 22:28:46] ERROR Premature end of script headers: C:/atest/webrick/ruby/cgi
localhost - - [05/Aug/2005:22:28:45 Central Standard Time] "GET /cgi-bin/helloworld.cgi HTTP/1.1"
500 338
- -> /cgi-bin/helloworld.cgi
------------------------------------

What am I missing? Why is it saying "Permission Denied"?

Also, I would like to know if there is a trick to specify _multiple_ CGI interpreters, one of
which gets invoked based on the script language (ruby.exe if it is a .rb file, perl.exe if it is a
.pl file and python.exe if it is .py file. Of course, the actual extension for all the files will
be .cgi as per the requirements).

I am a newbie when it comes to web programming so I do not know if this even makes sense.

TIA,

-- shanko

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Oh god I hate cgi, first make sure the directroy's you mention have
execute permissions (dont know if this is important in windows)
then the cgi script must have execute permissions

make sure all the paths specified are correct.

make sure you have the #!/path to ruby.exe or whatever its windows
equivalent is at the start of the cgi script.

and if that doesnt work try installing apache & using regualar cgi
from there but with ruby, i think it would be more easy.

i personally recommend you keep away from cgi, it's ok for learning or
something very very simple but anything remotly complicated & it
becomes a pain.

thats just my experience.

···

--
My Blog: http://27degrees.blogspot.org