Common Gateway Interface - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Common Gateway Interface

FirestormFirestorm Posts: 162Member
Hi,
I would like to know what exactly this CGI is.
I only know what this 3 letters stand for but I can't imagine anything under that.
I mean why do you talk of PERL as a CGI language but you don't do so with PHP. What are other CGI languages. Why do people think this system is about to die out?
thx
[size=1]Hope someone will find this post in this forum although it is kind of empty... :-/ [/size]
________________________________
[red]http://www.againsttcpa.com[/red]
[blue]Don't give big brother a chance![/blue]

Comments

  • JonathanJonathan Posts: 2,914Member
    Hi,

    : I would like to know what exactly this CGI is.
    : I only know what this 3 letters stand for but I can't imagine
    : anything under that.
    CGI is a standard way for a web server to interface with an external program that takes input that the server has recieved and generates a page dynamically based upon it. Thus the common bit is becuase it's a standard, gateway because it's the way data is passed between two systems, and interface because it's what's between two systems. Or something like that...

    Basically, the web server sets several environment variables detailing the request, and then any data that was sent using the POST method is sent to STDIN. The CGI program is then responsible for reading and parsing that data coming from the web server. It prints any output to go to the browser to STDOUT, and then the web server passed that data on to the end user who made the request. So it's basically User request --> Web Server --> CGI Program --> Web Server --> Response to user.

    : I mean why do you talk of PERL as a CGI language but you don't do so
    : with PHP. What are other CGI languages.
    PHP is generally not talked of as a CGI language because the vast majority of the time it runs as a module in the web server. You can use PHP in CGI mode if you want, but generally people don't. OTOH, Perl when used for web stuff traditionally uses the CGI route. I believe the web server module route wasn't open to it when people started using Perl for doing web stuff. However, these days, we have mod_perl which enables Perl to run as a web server module rather than CGI. It's just that not everyone uses it. :-)

    Note developing CGI is only one application of Perl, and it wasn't designed just for doing CGI; any programming language that can take data on STDIN and through environment variables and shove data to STDOUT can be used. So that's C, Python, even VB, etc...most programming languages are suitable. Usually compiled languages such as C are not used as you have to re-compile the CGI everytime it needs changing. Then, C ones will be faster.

    : Why do people think this system is about to die out?
    I don't think it's about to die out real soon, but it has got one significant issue - resource usage. Everytime you run a Perl CGI a new proccess has to be forked, the Perl program needs to start, the script needs to be compiled...etc, etc. This has a fairly significant resource overhead. But hey, at least when it runs as a seperate proccess it can't trash your web server proccess, which I've heard several badly (and hopefully unfortunately) written PHP scripts being able to do.

    : [size=1]Hope someone will find this post in this forum although it is
    : kind of empty... :-/ [/size]
    Yeah, this is a fairly quiet forum so it's nice to have the odd post every so often. (As the mod, I check it regularly though!)

    Time to go prepare for hard exam this afternoon...

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • infidelinfidel Posts: 2,900Member
    : : Why do people think this system is about to die out?
    : I don't think it's about to die out real soon, but it has got one significant issue - resource usage. Everytime you run a Perl CGI a new proccess has to be forked, the Perl program needs to start, the script needs to be compiled...etc, etc. This has a fairly significant resource overhead. But hey, at least when it runs as a seperate proccess it can't trash your web server proccess, which I've heard several badly (and hopefully unfortunately) written PHP scripts being able to do.

    The world is moving slowly towards Webapp servers. CGI just doesn't have the flexibility to do as much as people need to run complex applications across the internet.

    : : [size=1]Hope someone will find this post in this forum although it is
    : : kind of empty... :-/ [/size]
    : Yeah, this is a fairly quiet forum so it's nice to have the odd post every so often. (As the mod, I check it regularly though!)

    I created the Free Software board and it's slower than this one. I also volunteered to take over the Python board, which is a little busier than this one. It seems that the only board here I visit that gets any real traffic is the VB board.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • SNIPERBBBSNIPERBBB Posts: 41Member
    One thing is, its hard to find a site that has good C CGI tutorials without having to learn someones library. As mentioned before, ASP,JSP, and PHP are starting to take over. Unless you are a commercial webmaster then its going ot be hard ot find a site that offers free hosting for the 3 above with enough storage. If anyone knows a good site that has a good C CGI tutorial email me, [email protected] or post it on my forum at http://sniperbbb0.tripod.com , just click on the forum link on the right.
  • Homerun31Homerun31 Posts: 99Member
    I know PHP and it uses a MySQL database to get stuff onto the webpage what kind of thing does CGI use? or does it use the same thing
  • JonathanJonathan Posts: 2,914Member
    : I know PHP and it uses a MySQL database to get stuff onto the
    : webpage what kind of thing does CGI use? or does it use the same
    : thing
    CGI is just a method of "connecting" a script written in some language with the web server. Basically, in CGI the server sets environment variables and some data gets piped to STDIN and what is printed to STDOUT gets sent to the browser. Simple, but you have to launch a proccess for each request then it could get expensive in terms of resources. So PHP by default runs as an Apache (or IIS) module.

    CGIs can be written in almost any programming language, including PHP, Perl, Python, C, even VB. And yes, you can still do all the usual stuff like connect to MySQL and all that lot.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.