CGI Environment variables include a series of hidden values that
the web server makes available to the CGI programmer.
These variables include the name of the HTTP server software
and server IP address. These variables also include useful
information about the user, such as his browser and IP address.
In this case the CGI program being run is written in RPG.
The RPG program retrieves the environment variables and prints them below.
| Variable | Value | Explanation |
| DOCUMENT_ROOT | /cgidev/conf/hotdocs  | The root directory of your server |
| HTTP_COOKIE |   | The visitor's cookie, if one is set |
| HTTP_HOST | as400.liberty-i.net  | The hostname of the page being attempted |
| HTTP_REFERER |   | The URL of the page that called your program |
| HTTP_USER_AGENT | CCBot/1.0 (+http://www.commoncrawl.org/bot.html)  | The browser type of the visitor |
| HTTPS | OFF  | "on" if the program is being called through a secure server |
| PATH | /bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin  | The system path your server is running under |
| QUERY_STRING |   | The query string (see GET, below) |
| REMOTE_ADDR | 38.103.63.57  | The IP address of the visitor |
| REMOTE_HOST |   | The hostname of the visitor (if your server has reverse-name-lookups on; otherwise this is the IP address again) |
| REMOTE_PORT | 57083  | The port the visitor is connected to on the web server |
| REMOTE_USER |   | The visitor's username. This would show up had you had to log into this web site with a user name and password. Note that this parameter will be blanks as some as the user moved to a library/directory that is not protected. |
| REMOTE_IDENT |   | If the HTTP server supports RFC 931 identification, then this variable will be set to the remote user name retrieved from the server. Usage of this variable should be limited to logging only. |
| REQUEST_METHOD | GET  | GET or POST |
| REQUEST_URI | _`ÄÅÑ%ÑÂø&å(‘øÅ_  | The interpreted pathname of the requested document or CGI (relative to the document root) |
| SCRIPT_FILENAME | /qsys.lib/mycgilib.lib/PGM21.pgm | The full pathname of the current CGI |
| SCRIPT_NAME | /mycgilibp/PGM21.pgm | The interpreted pathname of the current CGI (relative to the document root) |
| SERVER_ADMIN | [no address given] | The email address for your server's webmaster |
| SERVER_NAME | as400.liberty-i.net | Your server's fully qualified domain name. |
| SERVER_PORT | 80 | The port number your server is listening on |
| SERVER_SOFTWARE | Apache | The server software you're using (e.g. Apache 1.3) |
Here is an extract of the code that retrieves some environmental viariables and in the same line pueshes the retrieved values to the HTML page.
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq....Comments++++++++++++
c GetEnvVars Begsr
c callp UpdHtmlVar('DOCUMENT_ROOT ':
c getenv('DOCUMENT_ROOT':qusec) + ' ')
c
c callp UpdHtmlVar('HTTP_COOKIE':
c getenv('HTTP_COOKIE':qusec) + ' ')
c
c callp UpdHtmlVar('HTTP_HOST':
c getenv('HTTP_HOST':qusec) + ' ')
c
c callp UpdHtmlVar('HTTP_REFERER':
c getenv('HTTP_REFERER':qusec) + ' ')
c
c callp UpdHtmlVar('HTTP_USER_AGENT':
c getenv('HTTP_USER_AGENT':qusec) + ' ')
c
c callp UpdHtmlVar('HTTPS':
c getenv('HTTPS':qusec) + ' ')
|