Naive CGI question

This builder.com article from May 2002 uses Perl’s CGI::Batch.pm to do
what Hal’s asking about.

http://builder.com.com/article.jhtml?id=u00220020510gcn01.htm

Al

···

-----Original Message-----
From: Justin White [mailto:just6979@yahoo.com]
Sent: Friday, May 23, 2003 1:43 PM
To: ruby-talk ML
Subject: Re: Naive CGI question

Hal E. Fulton wrote:

It’s not entirely obvious to me that
a web server is needed to run a CGI
that is on the local machine. (As,
by analogy, we don’t need to run a
server just to look at local static
HTML files.)

So, a serverless CGI – possible in
theory and practice, in theory only,
or just not happening?

Hal

with CGI, the HTTP server simply runs the script, providing it with
environment variables (the global ENV hash in Ruby). the variables (see
http://tin.2t.net/scripts/envlist.rb for an example) contain the
requested URL, including all the stuff after the ? in GETs and including

all the sent data in POSTs. the script then operates on this data and
its output is then sent by the server to the browser.

both Perl’s CGI.pm and Ruby’s cgi.rb recognize when they’re not being
run via a server and ask for the information, dumping the output to
stdout. while you can save that output into a file and view it, it’s
definitely more work that just typing a URL.

have you considered running a server locally? Apache needs only a few
configuration changes to be able to run Ruby scripts as CGIs (none if
give them .cgi extensions, IIRC), and it’s free :wink:

or perhaps someone would like to create a little Ruby app to answer http

requests,fill out the ENV, and run a script. run minicgi.rb somescript.rb and point a browser at http://localhost/?cgidata=goeshere

(where somescript.rb is the CGI script you want to test)

-Justin