How to compile CGI program

Source: Internet
Author: User

 

  CGI (Common Gateway Interface) is a standard Interface for WEB servers to provide information services. Through this Interface, WEB servers can execute programs, and return the information output by the program to the browser. Because data on the WEB is static, CGI programs can dynamically process viewer requests, such as saving user input information and returning relevant information based on user information. After the client sends a CGI request to the WEB server, the WEB server determines the data transmission method to the CGI program based on the CGI program type, generally, data is transmitted with CGI programs through standard input/output streams and environment variables.


CGI Input and Output principles

  CGI Input/Output Method: CGI program uses standard input (STDIN) and standard output (STDOUT) for input and output. STDIN and STDOUT are two pre-defined file pointers. You can use the file read/write function to manipulate it.

In additionCGI programs also get input through environment variables, except that the environment variables provide some common information, this usually does not include the information you enter on the WEB page (except when using the GET method described below, you can check the environment variable QUERY_STRING to obtain the input data ), STDIN is usually used to transmit user input information. In general CGI program development, we need to care about the following environment variables:

In partEnvironment variables related to WEB servers:

  • SERVER_NAME WEB server name
  • SERVER_PORT WEB server listening address
  • SERVER_PROTOCOL Protocol name and version used to send the request
  • SERVER_SOFTWARE WEB server name and version

Part of the operation isCGI-related:

  • REQUEST_METHOD Data transmission (Information Transmission) Method
  • CONTENT_LENGTH Data Length
  • QUERY_STRING
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.