[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Webrick & CGI programs on WinXP

Austin Ziegler

9/22/2003 5:10:00 PM

I'm attempting to get ruwiki running under WEBrick on Windows XP. It's not
working, so I am attempting with a very simple CGI script. Well, that isn't
working, either.

I'm starting WEBrick with:
----------------
#!/usr/local/bin/ruby
require 'webrick'
include WEBrick

s = HTTPServer.new(:Port => 2000, :DocumentRoot => Dir::pwd + "/htdocs")

# mount subdirectories
s.mount("/ruwiki", HTTPServlet::CGIHandler, "C:/Apps/Ruby18/bin/ruby.exe")

trap("INT"){ s.shutdown }
s.start
----------------

My CGI script is currently called hello.rb, but I've tried it as hello.cgi
as well and it doesn't work:
----------------
#!C:/Apps/Ruby18/bin/ruby.exe

# hello.pl -- my first perl script!

print "Content-type: text/html\n\n"

print <<"EOF"
<HTML>

<HEAD>
<TITLE>Hello, world!</TITLE>
</HEAD>

<BODY>
<H1>Hello, world!</H1>
</BODY>

</HTML>
EOF
----------------

Here's the error message:
[2003-09-22 13:00:11] INFO WEBrick 1.3.1
[2003-09-22 13:00:11] INFO ruby 1.8.0 (2003-08-04) [i386-mswin32]
[2003-09-22 13:00:11] INFO WEBrick::HTTPServer#start: pid=3268 port=2000
[2003-09-22 13:00:20] ERROR Errno::EACCES: Permission denied -
C:\DOCUME~1\Austin\LOCALS~1\Temp/webrick.cgiout.3268.0
c:/Apps/Ruby18/lib/ruby/1.8/tempfile.rb:143:in `unlink'
c:/Apps/Ruby18/lib/ruby/1.8/tempfile.rb:143:in `callback'
c:/Apps/Ruby18/lib/ruby/1.8/tempfile.rb:134:in `call'
c:/Apps/Ruby18/lib/ruby/1.8/tempfile.rb:99:in `close!'
c:/Apps/Ruby18/lib/ruby/1.8/tempfile.rb:90:in `close'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/httpservlet/cgihandler.rb:59:in
`do_GET'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in
`__send__'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in
`service'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/httpserver.rb:92:in `service'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/httpserver.rb:54:in `run'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:168:in `start_thread'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:114:in `start'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:109:in `each'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:109:in `start'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:99:in `start'
c:/Apps/Ruby18/lib/ruby/1.8/webrick/server.rb:99:in `start'
c:/tmp/webrick/server.rb:13
localhost - - [22/Sep/2003:13:00:19 Eastern Daylight Time] "GET
/ruwiki/hello.rb HTTP/1.1" 500 354
- -> /ruwiki/hello.rb

-austin
--
austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.09.22
* 12.44.34



3 Answers

Eric Hodel

9/22/2003 6:05:00 PM

0

Austin Ziegler (austin@halostatue.ca) wrote:

> I''m attempting to get ruwiki running under WEBrick on Windows XP. It''s not
> working, so I am attempting with a very simple CGI script. Well, that isn''t
> working, either.

WEBrick has too many UNIX-isms to work well on a microsoft platform,
I''ve got it working though.

In cgihandler.rb add ``<< ::Conifg::CONFIG[''EXEEXT'']'''' to line 21, so
the correct name of the ruby interpreter is used.

I had to add quotes to line 22 to use the correct path, because my ruby
is installed in a non-standard location:

CGIRunner = "\"#{Ruby}\" \"#{Config::LIBDIR}/httpservlet/cgi_runner.rb\""

I had to start WEBrick with a CGIInterpreter:

s = WEBrick::HTTPServer.new(:CGIInterpreter => "\"#{WEBrick::HTTPServlet::CGIHandler::Ruby}\"")

I was then able to use a CGI:

s.mount("/hi", WEBrick::HTTPServlet::CGIHandler. "cgi.rb")

where cgi.rb was:

print "content-type: text/plain\r\n\r\n"

puts "hi"


--
Eric Hodel - drbrain@segment7.net - http://se...
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

GOTOU Yuuzou

9/22/2003 7:18:00 PM

0

GOTOU Yuuzou

9/22/2003 7:48:00 PM

0