These programs are most often served from a directly called /cgi-bin/ but
CGI sends most information concerning an http request from the server to the program via OS Environment Variables. The remaining information (usually only used for the POST data transfer method) is sent to the stdin of the program and will be of a length given in the %CONTENT_LENGTH% variable.
Here is an example of the information sent to a CGI program (the Win32AsmCGI program)
%SERVER_SOFTWARE% = Microsoft-IIS/4.0 %SERVER_NAME% = 192.168.0.5 %GATEWAY_INTERFACE% = CGI/1.1 %SERVER_PROTOCOL% = HTTP/1.1 %SERVER_PORT% = 80 %REQUEST_METHOD% = POST %PATH_TRANSLATED% = h:\Inetpub\wwwroot %SCRIPT_NAME% = /cgi-bin/asmcgi.exe %QUERY_STRING% = get=still %REMOTE_HOST% = 192.168.0.6 %REMOTE_ADDR% = 192.168.0.6 %CONTENT_TYPE% = application/x-www-form-urlencoded %CONTENT_LENGTH% = 47 %HTTP_ACCEPT% = application/msword, application/vnd.ms-excel, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* %HTTP_USER_AGENT% = Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
Output from the script is returned to stdout and in order to tell the server what kind of document you are sending back, whether it be a full document or a reference to one, CGI requires you to place a short header on your output. This header is ASCII text, consisting of lines separated by either linefeeds or carriage returns (or both) followed by a single blank line. The output body then follows in whatever native format.
For example, to send back HTML to the client, your output should read:
Content-type: text/html <HTML><HEAD> <TITLE>output of HTML from CGI script</TITLE> </HEAD><BODY> <H1>Sample output</H1> What do you think of <STRONG>this?</STRONG> </BODY></HTML>
Also:
See also:
| file: /Techref/inet/cgi.htm, 2KB, , updated: 2001/6/21 12:36, local time: 2012/5/22 08:49,
38.107.179.230:LOG IN |
| ©2012 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.ecomorder.com/techref/inet/cgi.htm"> Internet Web Server CGI</A> |
| Did you find what you needed? |
Robotics nuts!Check out http://users.frii.com/dlc/robotics/projects/botproj.htm from Dennis Clark. This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.