Index: [Article Count Order] [Thread]

Date: Sat, 30 Aug 2003 09:27:16 -0400
From: Mark Wilson <mwilson13@cox.net>
Subject: [webricken:118] Getting cgi scripts to work
To: webricken@notwork.org
Message-Id: <AC803256-DAED-11D7-B360-000393876156@cox.net>
X-Mail-Count: 00118

I'll show code and output to describe the problem I'm having. I'm aware 
that my problem may be with web servers generally and not webrick 
specifically, but I still need help.

-------------------------------------------------------------

Server 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

-------------------------------------------------------------

'htdocs/index.html':

<p><a href="approx-time.html">approx-time.html</a></p>
<br>
<p><a href="cgi-bin/current-time.rb">current-time.rb</a></p>

-------------------------------------------------------------

'htdocs/cgi-bin/current-time.rb'

#!/usr/local/bin/ruby

print "Content-type: text/html\r\n\r\n"
puts "<html><body>"
puts "Current time: <b>#{Time.now}</b><br>"
puts "</body></html>"

-------------------------------------------------------------

Result of following 'current-time.rb' link from home page:

Internal Server Error
The server encontered a script error.
WEBrick/1.3.1 (Ruby/1.8.0/2003-08-04) at      localhost:2000

-------------------------------------------------------------

Output of 'ls -Fla htdocs/cgi-bin'

total 4
drwxr-xr-x    3 markwils wheel         102 Aug 30 09:24 ./
drwxr-x---    8 markwils wheel         272 Aug 30 09:07 ../
-rwxr--r--    1 markwils wheel         142 Aug 30 09:10 current-time.rb*


Regards,

Mark