Webrick and CGI question

Discussion in 'Ruby' started by Mark Wilson, Aug 27, 2003.

  1. Mark Wilson

    Mark Wilson Guest

    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
    Mark Wilson, Aug 27, 2003
    #1
    1. Advertising

  2. Hi,

    > From: "Mark Wilson" <>
    > 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
    NAKAMURA, Hiroshi, Aug 27, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    107
    GOTOU Yuuzou
    Sep 23, 2003
  2. Ben Giddings

    CGI and Webrick

    Ben Giddings, Oct 3, 2003, in forum: Ruby
    Replies:
    2
    Views:
    124
    John W. Long
    Oct 4, 2003
  3. Lloyd Zusman
    Replies:
    2
    Views:
    382
  4. Steve Appling

    webrick and CGI module

    Steve Appling, Nov 9, 2005, in forum: Ruby
    Replies:
    0
    Views:
    85
    Steve Appling
    Nov 9, 2005
  5. Aaron Smith

    WEBrick::Daemon and WEBrick

    Aaron Smith, Mar 9, 2007, in forum: Ruby
    Replies:
    2
    Views:
    299
    Aaron Smith
    Mar 18, 2007
Loading...

Share This Page