CGI Development

Moderators: Jonathan
Number of threads: 57
Number of posts: 124

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Common Gateway Interface Posted by Firestorm on 16 Jun 2003 at 10:53 AM
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
Hope someone will find this post in this forum although it is kind of empty... :-/
________________________________
http://www.againsttcpa.com
Don't give big brother a chance!
Report
Re: Common Gateway Interface Posted by Jonathan on 17 Jun 2003 at 1:21 AM
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.

: Hope someone will find this post in this forum although it is
: kind of empty... :-/

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.");

Report
Re: Common Gateway Interface Posted by infidel on 17 Jun 2003 at 7:13 AM
: : 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.

: : Hope someone will find this post in this forum although it is
: : kind of empty... :-/

: 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.


infidel

Report
Re: Common Gateway Interface Posted by SNIPERBBB on 18 Aug 2003 at 7:05 PM
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, sniperbbb@hotmail.com or post it on my forum at http://sniperbbb0.tripod.com , just click on the forum link on the right.
Report
Re: Common Gateway Interface Posted by Homerun31 on 9 Sept 2003 at 2:11 PM
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
Report
Re: Common Gateway Interface Posted by Jonathan on 9 Sept 2003 at 2:35 PM
: 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.");




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.