Run CGI scripts in own webserver

Hello,

Does anybody know how I can run ruby cgi scripts in my web server. I
coded the webserver myself in ruby. At this moment I use ERB to parse
the .rhtml files. It all works fine but now i want to use the
functionality of CGI to extend my webserver. So I would like to read the
CGI file, parse it and send my html output to the user’s webbrowser.

So does anybody knows how to run a CGI file?

On Mon, Mar 21, 2011 at 3:11 PM, Kevin Kevin
[email protected]wrote:

Hello,

Does anybody know how I can run ruby cgi scripts in my web server. I
coded the webserver myself in ruby. At this moment I use ERB to parse
the .rhtml files. It all works fine but now i want to use the
functionality of CGI to extend my webserver. So I would like to read the
CGI file, parse it and send my html output to the user’s webbrowser.

So does anybody knows how to run a CGI file?

CGI is part of standard lib. try ruby uses it (until i can get a
sessions
issue worked out in rails).

Andrew McElroy
http://tryruby.org

On Mon, Mar 21, 2011 at 9:11 PM, Kevin Kevin
[email protected] wrote:

Hello,

Does anybody know how I can run ruby cgi scripts in my web server. I
coded the webserver myself in ruby. At this moment I use ERB to parse
the .rhtml files. It all works fine but now i want to use the
functionality of CGI to extend my webserver. So I would like to read the
CGI file, parse it and send my html output to the user’s webbrowser.

So does anybody knows how to run a CGI file?

That depends on your webserver. Apache has the fast_cgi module, which
should help you in getting up to speed, if you use Apache. I’m certain
lighttp and NGinx have similar modules/plugins/whatever to facilitate
CGI.

And I think Ruby’s Webrick HTTP server-cum-library should be able to
serve Ruby CGI scripts.


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.

Andrew Mcelroy wrote in post #988626:

CGI is part of standard lib. try ruby uses it (until i can get a

He can use Sinatra or some other Rack-based framework. Rack supports the
CGI interface. (Well, it’s supposed to; I haven’t actually tried it.)
This will save him the work of converting the code in the future if he
decides to move away from CGI.

Phillip G. wrote in post #988633:

On Mon, Mar 21, 2011 at 9:11 PM, Kevin Kevin
[email protected] wrote:

Hello,

Does anybody know how I can run ruby cgi scripts in my web server. I
coded the webserver myself in ruby. At this moment I use ERB to parse
the .rhtml files. It all works fine but now i want to use the
functionality of CGI to extend my webserver. So I would like to read the
CGI file, parse it and send my html output to the user’s webbrowser.

So does anybody knows how to run a CGI file?

That depends on your webserver.

As the op stated, he wrote his own server.

On Mon, Mar 21, 2011 at 5:18 PM, andrew mcelroy [email protected]
wrote:

CGI file, parse it and send my html output to the user’s webbrowser.

So does anybody knows how to run a CGI file?

CGI is part of standard lib. try ruby uses it (until i can get a sessions
issue worked out in rails).

I should clarify that try ruby is open source:
http://github.com/sophrinix/TryRuby
the /public directory is the ruby CGI 1.9.2 based version. it will show
you
how to write a ruby cgi website. I didn’t mean that to come off as self
promoting as it may of sounded.

Andrew McElroy
http://TryRuby.org

Kevin DeValck wrote in post #988602:

Does anybody know how I can run ruby cgi scripts in my web server. I
coded the webserver myself in ruby.

You need to implement the (obsolete) CGI spec yourself in your server:
http://w3.org/CGI/
http://graphcomp.com/info/specs/cgi11.html
See also RFC 3875

You could spawn the process yourself using IO.popen, but the trouble is
setting the environment variables first in a thread-safe way. Probably
better to use IO.pipe, fork and exec. Look at the source for open3.rb in
the standard library.

I’m sure this will be an interesting learning exercise about how CGI
works, but most people have abandoned CGI anyway because it’s hugely
inefficient. So if I were you, I’d be looking at Rack instead, or at
least FastCGI or SCGI.

HTH,

Brian.

On Tue, Mar 22, 2011 at 2:06 AM, 7stud – [email protected]
wrote:

As the op stated, he wrote his own server.

Which I failed to parse completely. d’oh


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs