Common Gateway Interface - CGI
The Common Gateway Interface (CGI) program is used to provide interactivity to web applications so that they become responsive and dynamic to the requests made by a web browser or a client application. A CGI program contains a set of conventions that enable the client programs and the web servers to communicate. The web server usually acts as an intermediary between the CGI program and the client browser. When a client browser sends a request to the web server, it executes the CGI program based on the input received and sends the output back to the web browser for processing.
A commonly known example is a program that receives a stock ticker symbol as an input and returns relevant information about the stock including its current price. Another example is a program that accepts information about a website from a user and sends it to the webmaster as a feedback. CGI programs can be written in any programming language and they can also be used to interact with other programs or CGI programs during their execution.
A CGI program would not do the following.
1. it does not interact with a user directly.
2. It does not interact directly with a web browser or a graphical interface. In other words it does not display or retrieve information from menus, commands and other interactive features of a client browser.
3. It does not create graphics or windows by itself.
A program must meet the following criteria to be qualified as a CGI program.
1. One should be able to execute it directly by typing its name from the command line. A java program does not qualify to be a CGI program because it cannot be executed in the java virtual machine unless we type "java program-name" in the command prompt.
2. The program should generate a valid content-type header.1
Following are some of the advantages and disadvantages of CGI programs.
1. CGI programs are portable and work on a wide variety of web servers and platforms.
2. They are language independent. You can write then in any language and make them work in a wide variety of environments. Some of the programming languages good enough to write your CGI scripts are Perl, UNIX Shell, C language, Visual Basic, Python, C# and Java.
3. They provide simple interfaces for the clients to interact with the web servers.
4. They are scalable programs and you can use them to perform simple tasks in the application layer as well as more complex tasks such as interacting with databases and shopping carts.
5. They provide interactivity to a web application and enhance user experience.
6. CGI programs are cost effective. By using them businesses can lower their development and maintenance costs.
1. The CGI programs are memory intensive programs. Every time a request is made to a server, it has to launch the CGI program. If they are written in a scripting language, the interpreter for the scripting language has to evaluate the entire script to execute the CGI program each time the program is initiated. If the server has busy traffic, repeated client side requests would consume a great deal of server resources and impact server performance. This problem is minimized to some extent by CGI scripts written in a compiled or interpreted language like C where there is no need for an interpreter to read the CGI program code separately.
2. CGI programs are not easy to write. They require complex programming and designing skills on the part of the web developers since a lot depends upon how they are implemented in the server environment.
3. If proper care is not taken, CGI programs may compromise server security.
4. Most of the CGI programs are well known, free and easily available. Their strengths and vulnerabilities are known to most web developers. This often result in their exploitation and misuse.
CGI was developed at National Center for Supercomputing Applications (NCSA) during the initial phases of development of the first web server that went by the name NCSA HTTPD. It was added to the server during the 1.0 release. NCSA was the place where most of founders of Netscape worked. During the development of the web server, Rob McCool created an initial specification for an interactive process with in the web server functionality, before it was recognized as a separate and independent CGI program.
CGI programs may accept as inputs html code, graphics, word documents, binary input, text files, audio and video files and so on. The data is usually submitted through web forms or programmatically through preexisting objects such as components and other executable programs. CGI programs may not perform as expected unless they receive valid input. So validation checks are necessary before the data is passed on to them.
Because of the limitations in developing and executing CGI programs and the disadvantages we have discussed above, many CGI alternatives have been developed and marketed commercially in recent years. Most of these are proprietary solutions that attempt to tackle the problems associated with CGI applications. Some of these alternatives like ASP, Cold Fusion and PHP are HTML based where you embed scripts in the HTML code and some like mod_perl, NSAPI and ISAPI interface directly with the web server without a CGI interface.
Following are some of the well known websites where you will find tons of cgi scripts and examples.
CGI City -CGI City was formed with the purpose of providing a one-stop-shop for people with CGI requirements. We have taken great efforts to put together a very comprehensive set of links that will address most, if not all, of your CGI needs. This site caters to all people from all over the world with no discrimination for CGI proficiency. Our packaged cgi scripts have been sold to customers in 16 different countries. Similarly, our custom programming services have been contracted by customers from various cities all over the world. A novice as well as the seasoned CGI programmer and even the non-programmers will find CGI City a useful site worth bookmarking.
Perl.Com - Perl.com is the central web site for the Perl community. Launched by Tom Christiansen, perl.com provides a starting place for finding out everything about Perl. O'Reilly & Associates, Inc., the premier publisher of books about Perl, is the sponsor of perl.com and the goal is to make perl.com an even better resource for programmers, new and advanced
WillMaster.com -CGI is fast becoming essential to many online businesses. WillMaster.com offers a wide variety of powerful programs: Tools for Communication, Site content, Site promotion, Forms processing, E-zines, E-mailing, Web site administration. You can use WillMaster.com CGI programs to automate your site, facilitate sales, foster trust, and bring your customers back for more.
Matt's Script Archive, Inc: Welcome to Matt's Script Archive. Offering free CGI scripts to the web community since 1995. Get your free Perl CGI scripts for FormMail, Guestbook, WWWBoard, Simple Search, csPublisher, Article Manager, Counter, TextCounter, Random Text, TextClock, Free for all Links, Random Link, HTTP Cookie Library, Countdown, Random Image, SSI Random Image, TextCounter, C++, TextClock, C++.
CPAN - CPAN is the Comprehensive Perl Archive Network, a large collection of Perl software and documentation. You can begin exploring from either //www.cpan.org/, //www.perl.com/CPAN/ or any of the mirrors listed at //www.cpan.org/SITES.html and //mirror.cpan.org/. Note that CPAN is also the name of a Perl module, CPAN.pm, which is used to download and install Perl software from the CPAN archive. This FAQ covers only a little about the CPAN module and you may find the documentation for it by using perldoc CPAN via the command line or on the web at //theoryx5.uwinnipeg.ca/CPAN/perl/CPAN.html.
BigNoseBird: There are over 300 pages of tutorials, reference materials, and other free resources located on this site. The links below list major content areas. The collection includes form processing, guestbook, banner rotation, site search and more. You can also browse through several useful tutorials and articles.
CGI World - CGI-World.Com is a Department of i2-Services Incorporated. Operations began in 1996 offering interactive, web based internet polling software. Our goal since 1996 has been a dedication to Developing, Marketing, and Supporting high quality, full featured web based applications. Years later CGI-World.Com and our Partners have developed a wide variety of web based products that provide solutions to everyday web tasks.
Cliff's Perl Scripts - Welcome to my perl script collection! This page is designed for webmasters who are looking for free CGI scripts. If you don't fall into that category, I suggest you check out my unique brand of immature low-brow humor at Shaven Ferret Productions.
Free CGI/Perl Scripts - Easy to Use: Dozens of free and professional CGI / Perl scripts. Download our free CGI scripts, get to know our superior quality, then come back and check out the rest of our products. If you do not see the script you are looking for, we can custom build it for you. When you buy a script, it can be used on one domain only. If you want to extend the license, go here. If you want to see what we have in the works, look here.
Four-Runner.com: Welcome to Four-Runner.com - The IT Developers No.1 choice for resources of every description Developers available to design, program and/or your Internet and/or Intranet site and/or application: Online Enquiry Form.
LockedArea.com - LockedArea.com is the centre point for distribution of the internationally acclaimed Locked Area program. Locked Area is a very powerful Perl script designed for creating password protected member communities for web sites. It offers all the great features that you'd expect of a program of this type as well as some others like members area statistics, powerful administration panel and an easy to use, 60-second installation program.
PerlMonks.org : Welcome to the Perl Monastery. We hope your stay is long and enjoyable. You are probably wondering what Perl Monks is all about. Hopefully this page will answer some of those questions. What Perl Monks is: Our attempt to make learning Perl as nonintimidating and easy to use as possible A place for you and others to polish, improve, and showcase your Perl skills A community which allows everyone to grow and learn from each other.
Perl Circus: This site is about Perl. Its not actually about circuses but I definitely think a good Perl coder is a lot like a circus performer -- somewhere between a contortionist and a trainer of wild beasts. And I mean that in a good way!
CGIScriptReview.com: CGIScriptReview.com is basically aimed to be your one-stop resource for reviews of all the most popular CGI scripts available on the internet. We have reviews of all the most popular scripts available. To get started, please select a category to look in from the listing below to find and read a review. All reviews are written by people who are not associated with the script development so as to make sure they are honest and true to life. We currently have 10 CGI script related reviews listed.
Perl Coders: PerlCoders is a company started on the premise that webmasters should not have to pay an arm and leg for top quality programming. While most CGI programmers were charging a lot of money to make each script, we decided to start creating ready made solutions to common needs at membership pricing. What had started with one script has now become the largest single source for pre-made programs on the net.
ScriptSearch: ScriptSearch.com said to be the largest and most well-known programming directories anywhere. ScriptSearch's comprehensive programming directory is more intuitively organized by programming language with subfolders with various script categories. Rating features allow you to find the most popular and most useful resources according to the rest of our visitors. Its even a breeze to bookmark your favorite listings on your own "My Favorites" page, that you can easily return to. And there lots more inside.
Perl Foundation: The Perl Foundation is dedicated to the advancement of the Perl programming language through open discussion, collaboration, design, and code. The Perl Foundation coordinates the efforts of numerous grass-roots Perl-based groups including: International Yet Another Perl Conferences, Holds the copyright on Perl 6 and Parrot, perl.org, Perl Mongers, PerlMonks.
The CGI Resource Index: 4369 CGI resources listed in 339 categories at The CGI Resource Index.
CodeHound Perl - Unlike other Internet search engines, CodeHound is specifically designed for programmers. Instead of using a larger search engine like Google or AltaVista, a CodeHound user comes to CodeHound, selects a programming language, and lets CodeHound search the best Web sites and newsgroups dedicated to that language. For example, a search on our SQL search engine is categorized by RDMS: SQL Server, Oracle, IBM DB2, Informix, Sybase, Microsoft Access, MySQL, and others. No other search engine on the Internet offers such power!
dev.perl.org - Perl 6 - The official site for the development of Perl 6, the next generation of the Perl programming language.
Kamango.com: PERL Channel - Wide range of Perl scripts, programs and tutorials.
O'Reilly Network: Perl Weblog - Features links and commentary by a variety of authors.
O'Reilly Perl Center - Current and past products, resources, and news on O'Reilly and Associate's Perl involvement.
Perl Cabal - Humorous profiles of Perl luminaries.
The Perl Institute - Non-profit organization dedicated to making the incredibly useful Perl language even more useful for everyone. Supports Perl creators, developers, maintainers, and users. Recently disbanded, and is being incorporated into the Perl Mongers.
PerlParaphernalia - By Mark-Jason Dominus. Perl Advanced Techniques Handbook (drafts). Hints, articles, Perl modules, programs.
Perl Quiz - Test your knowledge of Perl by answering 15 questions at basic, intermediate or advanced level. Questions change every time.
CGI/Perl on the web - Archives of comp.lang.perl; documentation; scripts; and source code for perl.
use Perl - General discussion of perl and issues relating to it, Perl news.
Suggestions for Further Reading
- Common Gateway Interface - CGI
- CRM, Customer Relationship Management
- Data Warehouse and Data Mining Technologies
- Relational Databases
- DHTML Scripts - Resources For Dynamic Websites
- Domain Name Registration Services
- Ecommerce and Online Store Solutions
- Online Marketing Solutions and Promotions
- Essays on Information Technology
- Free Software, Tools and Applications
- Computer and Web Graphics
- HyperText Markup Language
- Html Tools for World Wide Web
- Java Programming language, Tutorials, Tools and Applets
- Computer Networks
- Computer Operating Systems
- OS X Mountain Lion and Parallels Desktop For Mac
- Perl Scripts - Resources for CGI and Perl Programming
- Programming Languages
- Project Management
- Search Engines and SEO
- Web design and Website development
- Best Web Hosting Services
- Web Resources and Web Tools
- Web Tools And Web Resources For The Web Masters
1. A Content-Type header specifies the nature of the data in the body of an entity, by giving type and subtype identifiers, and also auxiliary information that may be required in some cases.
Translate the Page