Webrick and CGI question

M

Mark Wilson

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 :)

Regards,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top