Webrick newbie question

S

Shashank Date

Hi,

I am playing with Webrick that comes with the latest one-click installer =
on Windows XP (Home).

I cannot get the CGIHandler to work correctly. Here is the HTTPServer scr=
ipt:

#######################################
require 'webrick'
include WEBrick

def start_webrick(config =3D {})
config.update:)Port =3D> 8080)
server =3D HTTPServer.new(config)
yield server if block_given?
server.mount("/docs", HTTPServlet::FileHandler, "C:/atest/webrick/ht=
docs" )
server.mount("/cgi-bin", HTTPServlet::CGIHandler, "C:/atest/webrick/ru=
by/cgi")
['INT', 'TERM'].each {|signal|
trap(signal) {server.shutdown}
}
server.start
end

start_webrick:)DocumentRoot =3D> "C:/atest/webrick",:CGIInterpreter =3D> =
"C:/ruby/bin/ruby.exe")

__END__

#######################################

If I create a simple helloworld.cgi script and save it under C:/atest/web=
rick/htdocs, then I can
run it using http://localhost:8080/docs/helloworld.cgi

But if I save the same script under C:/atest/webrick/ruby/cgi and invoke =
it as:
http://localhost:8080/cgi-bin/helloworld.cgi

I get "HTTP 500 - Internal server error" in the browser (I.E. 6.0 SP2) an=
d the following messages
at the console:
------------------------------------
<previous messages sniped>

[2005-08-05 22:28:46] ERROR CGIHandler: C:/atest/webrick/ruby/cgi:
C:/ruby/bin/ruby.exe: Permission denied -- C:/atest/webrick/ruby/cgi (Loa=
dError)
[2005-08-05 22:28:46] ERROR CGIHandler: C:/atest/webrick/ruby/cgi exit wi=
th 1
[2005-08-05 22:28:46] ERROR Premature end of script headers: C:/atest/web=
rick/ruby/cgi
localhost - - [05/Aug/2005:22:28:45 Central Standard Time] "GET /cgi-bin/=
helloworld.cgi HTTP/1.1"
500 338
- -> /cgi-bin/helloworld.cgi
------------------------------------

What am I missing? Why is it saying "Permission Denied"?

Also, I would like to know if there is a trick to specify _multiple_ CGI =
interpreters, one of
which gets invoked based on the script language (ruby.exe if it is a .rb =
file, perl.exe if it is a
pl file and python.exe if it is .py file. Of course, the actual extensio=
n for all the files will
be .cgi as per the requirements).=20

I am a newbie when it comes to web programming so I do not know if this e=
ven makes sense.

TIA,

-- shanko

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20
 
J

James McCarthy

Oh god I hate cgi, first make sure the directroy's you mention have
execute permissions (dont know if this is important in windows)
then the cgi script must have execute permissions

make sure all the paths specified are correct.

make sure you have the #!/path to ruby.exe or whatever its windows
equivalent is at the start of the cgi script.

and if that doesnt work try installing apache & using regualar cgi
from there but with ruby, i think it would be more easy.

i personally recommend you keep away from cgi, it's ok for learning or
something very very simple but anything remotly complicated & it
becomes a pain.

thats just my experience.

--=20
My Blog: http://27degrees.blogspot.org
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top