Webrick and CGI question

How do I tell Webrick to use ruby to execute a cgi program? The
following code example just shows me the script and not the result of
executing the program:

#!/usr/local/bin/ruby
require 'webrick’
include WEBrick

s = HTTPServer.new(
:Port => 2000,
:DocumentRoot => Dir::pwd + “/htdocs”
)
s.mount(“cgi-bin”, HTTPServlet::CGIHandler, ‘/usr/local/bin/ruby’)
trap(“INT”) { s.shutdown }
s.start

I’ve tried several variations of the above, googled the web and
ruby-talk, checked the RDoc for Webrick (nothing there, by the way),
looked at the source for HTTPServlet::CGIHandler, checked the Webrick
website, etc.

The file I point my browser to is in the ‘htdocs/cgi-bin’ directory and
both the directory and the file are made executable. I am also the
owner of the site directory, all subdirectories and all files.

Webrick strikes me as an excellent addition to Ruby and I am looking
forward to learning how to use it.

I am also looking forward to a “doh!” moment on my question :slight_smile:

Regards,

Mark

Hi,

From: “Mark Wilson” mwilson13@cox.net
Sent: Wednesday, August 27, 2003 2:12 PM

s.mount(“cgi-bin”, HTTPServlet::CGIHandler, ‘/usr/local/bin/ruby’)

Mount the handler to “/cgi-bin” not “cgi-bin” here.

Regards,
// NaHi