Is there a mail list or USENET group for lighttpd WEBrick questions. I posted a simple CGI question to this list last week and got one responce and that responce told me I was on the wrong list with Ruby based from / CGI questions. The code I posted looks correct but does not work giving a Routing Error. This makes me think something is wrong with the set up of WEBrick. I am only doing the default "rails someapp" and running WEBrick with script/server -p3020. The CGI does not work (original post below). This makes me think I need to go to some WEBrick knowledge. Where can I find it? john #################################################### Original post: #################################################### Ok .. if you are sensitive ... stop reading. I am totally new to setting up CGI. I am getting a routing error. Would someone be kind enough to help me? Please? Here is my form ... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Adobe GoLive" /> <title>Form | Contact A</title> </head> <body bgcolor="#ffffff"> <form action="cgi-bin/parse.rb" method="post" #I have tried get enctype="application/x-www-form-urlencoded"> #I have tried text/plain <table width="455" border="0" cellspacing="0" cellpadding="5"> <tr height="33"> <from stuff deleted> I put this in the public folder of a rails WEBrick app. Here is my Ruby CGI ... ################################################### #!/opt/local/bin/ruby -w text = "dog" print "Content-type: text/html\r\n\r\n" print "<HTML><BODY>" print "<B><I>Hello</I>, #{ text} !</B>" print "</BODY></HTML>" ################################################## I put this in cgi-bin directory in the same dir as the forms.html file. Permissions on the Ruby script where set to 775. My intention is not to handle any input from the forms.html file but just to get back a simple ""Hello dog" after the submit. here is what i get when i run WEBrick and hit the Submit button ... Routing Error Recognition failed for "cgi-bin/parse.rb" Can anyone help me. I am not sure if this is a problem with my code, WEBrick of the form. Thanks and don''t be shy .. i have a thick skin. john
There are some general Ruby lists here: http://www.ruby-lang.org/en/20020104.html And I''m still confused as to what you are trying to do. Ruby on Rails is not just a simple CGI tool. You say that you''re using a rails app, but then you are just trying to get a CGI script to fire. That''s not how rails works... it expects a specific directory structure of ruby files and uses those to process a given request URL. Simply doing myhost.com/cgi-bin/myrubyfile.rb is not going to work.... even remotely. If you are interested in using rails to serve dynamic content, you should read through some of the docs at rubyonrails.com. If you just want to get a CGI script to run, don''t bother with rails; look at the docs for you webserver on how to set up CGI scripts. As long as you have ruby installed and your shebang line is correct, the script should get run. Good luck. b John N. Alegre wrote:> Is there a mail list or USENET group for lighttpd WEBrick questions. > > I posted a simple CGI question to this list last week and got one > responce and that responce told me I was on the wrong list with Ruby > based from / CGI questions. > > The code I posted looks correct but does not work giving a Routing > Error. This makes me think something is wrong with the set up of > WEBrick. I am only doing the default "rails someapp" and running > WEBrick with script/server -p3020. The CGI does not work (original > post below). This makes me think I need to go to some WEBrick > knowledge. Where can I find it? > > john > > #################################################### > Original post: > #################################################### > Ok .. if you are sensitive ... stop reading. > > I am totally new to setting up CGI. I am getting a routing error. > Would someone be kind enough to help me? Please? > > Here is my form ... > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > <meta http-equiv="content-type" content="text/html;charset=utf-8" /> > <meta name="generator" content="Adobe GoLive" /> > <title>Form | Contact A</title> > </head> > > <body bgcolor="#ffffff"> > > <form action="cgi-bin/parse.rb" method="post" #I have tried get > enctype="application/x-www-form-urlencoded"> #I have tried text/plain > > <table width="455" border="0" cellspacing="0" cellpadding="5"> > <tr > height="33"> > <from stuff deleted> > > I put this in the public folder of a rails WEBrick app. > > Here is my Ruby CGI ... > > ################################################### > #!/opt/local/bin/ruby -w > > text = "dog" > print "Content-type: text/html\r\n\r\n" > print "<HTML><BODY>" > print "<B><I>Hello</I>, #{ text} !</B>" > print "</BODY></HTML>" > ################################################## > I put this in cgi-bin directory in the same dir as the forms.html > file. Permissions on the Ruby script where set to 775. My intention > is not to handle any input from the forms.html file but just to get > back a simple ""Hello dog" after the submit. > > here is what i get when i run WEBrick and hit the Submit button ... > > Routing Error > > Recognition failed for "cgi-bin/parse.rb" > > Can anyone help me. I am not sure if this is a problem with my code, > WEBrick of the form. > > Thanks and don''t be shy .. i have a thick skin. > > john > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thank you this is why I am asking for a lighttpd / WEBrick forum. I am using the Rails structure only to "create" an environment to run WEBrick from. I am then using WEBrick to try to do simple Ruby CGI. The script I posted in my original query does work in a simulated server environment (Komodo). I now just want to move this to a real server environment. I created a Rails directory and then im using WEBrick out of it just ... creating a directory, ... putting the CGI script in that dir, ... setting permissions to 775 and seeing if it works. It don''t. So I am now assuming there is a problem with my assumption that I can have a working web server out of a Rails set up that will do simple CGI. Peace john On Monday 06 March 2006 02:31, Ben Munat wrote:> You say that you''re using a Rails app, but then you are just trying > to get a CGI script to fire. That''s not how Rails works... it > expects a specific directory structure of ruby files and uses those > to process a given request URL. Simply doing > myhost.com/cgi-bin/myrubyfile.rb is not going to work.... even > remotely. > > If you are interested in using Rails to serve dynamic content, you > should read through some of the docs at rubyonRails.com. If you > just want to get a CGI script to run, don''t bother with Rails; look > at the docs for you webserver on how to set up CGI scripts. As long > as you have ruby installed and your shebang line is correct, the > script should get run.
Yeah, I don''t know anything about using WEBrick freestanding other than it should be possible (WEBrick pre-dates rails). And I think that any HTTP server should be able to do CGI since it''s just "run this and dump it''s output into the response stream"... more or less. Well, you should probably look through the docs: http://www.webrick.org/ http://www.lighttpd.net/ or for that matter... http://httpd.apache.org/ There should be something about running CGIs in there somewhere. I''d bag the whole idea of using a rails app though. All you really need is a cgi-bin directory and a public directory and the proper config in whatever server you are using. b PS: and I have no idea why I''m the only person answering you..... :-( John N. Alegre wrote:> Thank you this is why I am asking for a lighttpd / WEBrick forum. > > I am using the Rails structure only to "create" an environment to run > WEBrick from. I am then using WEBrick to try to do simple Ruby CGI. > The script I posted in my original query does work in a simulated > server environment (Komodo). I now just want to move this to a real > server environment. I created a Rails directory and then im using > WEBrick out of it just ... creating a directory, ... putting the CGI > script in that dir, ... setting permissions to 775 and seeing if it > works. It don''t. So I am now assuming there is a problem with my > assumption that I can have a working web server out of a Rails set up > that will do simple CGI. > > Peace > john > > On Monday 06 March 2006 02:31, Ben Munat wrote: > >>You say that you''re using a Rails app, but then you are just trying >>to get a CGI script to fire. That''s not how Rails works... it >>expects a specific directory structure of ruby files and uses those >>to process a given request URL. Simply doing >>myhost.com/cgi-bin/myrubyfile.rb is not going to work.... even >>remotely. >> >>If you are interested in using Rails to serve dynamic content, you >>should read through some of the docs at rubyonRails.com. If you >>just want to get a CGI script to run, don''t bother with Rails; look >>at the docs for you webserver on how to set up CGI scripts. As long >>as you have ruby installed and your shebang line is correct, the >>script should get run. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I''m not sure why you''d want to do that. If all you want is WEBrick, just require/include it in your ruby code and go from there. Have a look at the WEBrick docs (it''s a part of the Ruby distro--Rails not needed) Jamie On Mar 6, 2006, at 8:55 AM, John N. Alegre wrote:> Thank you this is why I am asking for a lighttpd / WEBrick forum. > > I am using the Rails structure only to "create" an environment to run > WEBrick from. I am then using WEBrick to try to do simple Ruby CGI. > The script I posted in my original query does work in a simulated > server environment (Komodo). I now just want to move this to a real > server environment. I created a Rails directory and then im using > WEBrick out of it just ... creating a directory, ... putting the CGI > script in that dir, ... setting permissions to 775 and seeing if it > works. It don''t. So I am now assuming there is a problem with my > assumption that I can have a working web server out of a Rails set up > that will do simple CGI. > > Peace > john > > On Monday 06 March 2006 02:31, Ben Munat wrote: >> You say that you''re using a Rails app, but then you are just trying >> to get a CGI script to fire. That''s not how Rails works... it >> expects a specific directory structure of ruby files and uses those >> to process a given request URL. Simply doing >> myhost.com/cgi-bin/myrubyfile.rb is not going to work.... even >> remotely. >> >> If you are interested in using Rails to serve dynamic content, you >> should read through some of the docs at rubyonRails.com. If you >> just want to get a CGI script to run, don''t bother with Rails; look >> at the docs for you webserver on how to set up CGI scripts. As long >> as you have ruby installed and your shebang line is correct, the >> script should get run. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
John- Hopefully this info should get you going with your cgi servlet. The following is a custom webrick servlet that will serve html or cgi scripts right out of the doc root that you specify: #!/usr/local/bin/ruby require ''webrick'' require ''webrick/cgi'' include WEBrick server = WEBrick::HTTPServer.new def start_webrick(config = {}) config.update(:Port => 8000) server = HTTPServer.new(config) yield server if block_given? [''INT'', ''TERM''].each {|signal| trap(signal) {server.shutdown} } server.start end start_webrick {|server| # replace the next line with your doc root that you want to use. doc_root = ''/Volumes/Users/ez/webrick'' server.mount("/", HTTPServlet::FileHandler, doc_root, {:FancyIndexing=>true}) } Save that code into a file and run it from the command line. You can change the port number that it uses in the start_webrick method. then just put your html and cgi scripts in the doc root and go to town. Your cgi scripts will need to have .cgi as the extension in order to work correctly. Here is a simple cgi script that you can test to see if things are working for you: #!/usr/bin/env ruby print "Content-type: text/plain\r\n\r\n" ENV.keys.sort.each{|k| puts "#{k} ==> #{ENV[k]}"} Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com