Interview Questions
What is CGI Scripting?
-
CGI is an abbreviation of Common Gateway Interface which is defined as a certain set of rules and standards to be followed while exchanging data and information between custom script and web server. Following are the facts about CGI standards,
- NCSA (National Center for Supercomputing Applications) is the organization which currently defines and maintains the CGI standards.
- CGI standard can be implemented in external gateway scripting programs to interface with HTTP servers.
- The latest version of CGI is CGI/1.1
CGI Scripts
The scripts which are created following this CGI standard to modify the HTTP server are termed as CGI Scripting. In order to understand what CGI scripts exactly are, let us first examine what happens on clicking a hyperlink during web browsing.
- Once the hyperlink is clicked, the browser will request the web server (like HTTP) to find the file specified in the URL.
- Once the request is received by the web server, it then searches for the respective file and either returns the file or a 'File Not Found' error message.
- The Web browser then receives the file or error message and displays it to the user.
Here, with the help of CGI scripts, the web server can be modified so that when the web browser requests with URL, instead of sending a file, the server can run a program to send a customized or appropriate result.
CGI Scripting Language
The scripting languages that can be used for creating CGI scripts are called CGI scripting languages. Popular CGI scripting languages are C++, C, Shell Script, PERL Script etc.
Structure of CGI Script
While writing CGI Scripts, the coder should follow a specific structure to get the desired result. Below are the typical steps followed to writing CGI Scripts.
- Script should read the input from STDIN (input from web browser)
- Apply functions and logics to process the data.
- Return the desired result to STDOUT (output to web browser)
Get in touch with training experts Get Free Quotes