Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: CGI program

by manishrathi (Beadle)
on Sep 23, 2009 at 15:41 UTC ( [id://797003]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI program
in thread CGI program

I did a lot reading before posting questions here and I am still confused.
In the book "CGI programming with Perl", it was stated that CGI is a protocol. Does it mean that its something like HTTP ? But for using HTTP or LDAP or SQL, we dont use any API. We just open the interface on client machine for LDAP and SQL and comunicate. For HTTP, we dont need to do anything as its default protocol. So my confusion is about CGI being protocol. How can CGI protocol be used ? If we put a perl script in cgi-bin dir, will it automatically use CGI protocol ?
Is CGI protocol and CGI API, two different things ?
CGI APIs are created using what language ?
There are a lot of Perl APIs available, then why CGI APIs are required ? If a program is written in Perl and CGI API is used in it, is that a Perl program or CGI Program ? What does it mean when .cgi extension is used ? When shall we use .cgi extension ?
Is CGI API in-built in a web server for use ?
What do you mean by "CGI specifies how a webserver can pass data to arbitrary programs" ? what is meant by "arbitrary programs" ?
How is CGI API created ? Why do we have to use CGI functionality ? What is it that CGI has which a Perl does not ?
Is it mandatory to use CGI to pass data to web server ? If we have not used CGI, how will data transfer to "arbitrary programs" ?
Please excuse me , if some questions are primary. ButI am confused and want to get rid of this confusion.

Replies are listed 'Best First'.
Re^3: CGI program
by rgiskard (Hermit) on Sep 23, 2009 at 16:08 UTC
    It is important to note that the Common Gateway Interface, or CGI, is language independent. Moritz points this out in his point #1. Because it is language independant, you can use Perl or any language that can run under the interface to provide web pages (i.e. bash+CGI, lisp+CGI, python+CGI, etc.).
Re^3: CGI program
by moritz (Cardinal) on Sep 23, 2009 at 18:10 UTC
    CGI states things like:
    • URL parameters are passed as command line parameters to the program
    • Certain environment variables contain other information, like the remote host, the request URL, the user (if authenticated via HTTP basic authentication) etc.
    • HTTP POST data is passed to the standard input of the program

    So you see that CGI is, like HTTP, a specified form to exchange data.

    Unlike HTTP the web server provides all information without asking first. Because CGI is not a networking protocol.

    Perl 6 - links to (nearly) everything that is Perl 6.
Re^3: CGI program
by Boldra (Deacon) on Sep 24, 2009 at 07:52 UTC
    I think most of your confusion is because you don't completely understand the difference between a protocol and a programming language.

    Here on perlmonks you will find many examples of Perl which don't use CGI. If you google 'CGI bash' or 'CGI BAT', you'll also find examples of CGI which don't use Perl.

    Another possible way to get the concepts clear in your head is to try using HTTP without a browser. Run telnet google.com 80 then type GET / and see what happens.

    If all else fails, just start using the language and the protocol, and come back when you have a more specific question.

Re^3: CGI program
by dsheroh (Monsignor) on Sep 24, 2009 at 10:53 UTC
    In the book "CGI programming with Perl", it was stated that CGI is a protocol. Does it mean that its something like HTTP ?

    Not quite. CGI is a protocol, but it is not a network protocol. It is a protocol defining a method which is used by web server software to interact with other software running on the same host.

    But for using HTTP or LDAP or SQL, we dont use any API. We just open the interface on client machine for LDAP and SQL and comunicate.

    And how do you "open the interface on the client machine"? You run a piece of software which uses the appropriate API to access the underlying protocol to communicate with the HTTP/LDAP/SQL server. Or, if you're writing the client software which does so, you either use an existing API to access the protocol or you implement the protocol yourself.

    If a program is written in Perl and CGI API is used in it, is that a Perl program or CGI Program ?

    Yes. It is both. It is a Perl program which uses CGI. It is also a CGI program written in Perl.

    What does it mean when .cgi extension is used ? When shall we use .cgi extension ?

    The .cgi extension is used to indicate to the web server software (Apache, IIS, etc.) that the file should be executed through the CGI interface instead of sending the file itself to clients requesting that URL. For Apache, this is established by the command "AddHandler cgi-script .cgi" in httpd.conf.

    Is CGI API in-built in a web server for use ?

    It depends on the server you're running. Apache implements CGI as an external module, mod_cgi. Other servers build it into the core feature set.

    What do you mean by "CGI specifies how a webserver can pass data to arbitrary programs" ? what is meant by "arbitrary programs" ?

    "Arbitrary" just means that it can be anything. CGI can be used by a web server to pass data to any program you choose without the server having to know anything special about the program that will be receiving the data.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://797003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found