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
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
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
"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