CGI/SHTML Environment Variables

One method that web servers use to pass information to a cgi script is through environmental variables. These are created and assigned values within the environment that the server spawns for the cgi script. They can be accessed as any other environmental variable, like with getenv() (in C) or %ENV{'VARIABLE_NAME'} (in Perl). Many of them, contain important information, that most cgi programs need to take into account. This list, shows the most commonly used ones, along with the browser output.

SHTML web pages can access them as: <!--#echo var="VarName" -->

 

HTML Comment Browser Output
<!--#echo var="auth_type" --> (none)
<!--#echo var="content_length" --> (none)
<!--#echo var="content_type" --> (none)
<!--#echo var="date_local" --> Tuesday, 30-Apr-2013 12:21:41 EDT
<!--#echo var="date_gmt" --> Tuesday, 30-Apr-2013 16:21:41 GMT
<!--#echo var="document_name" --> ref_cgi_codes.shtml
<!--#echo var="document_root" --> /usr/home/web
<!--#echo var="document_uri" --> /~evrsoft/ref_cgi_codes.shtml
<!--#echo var="forwarded" --> (none)
<!--#echo var="from" --> (none)
<!--#echo var="gateway_interface" --> CGI/1.1
<!--#echo var="http_accept" --> */*
<!--#echo var="http_accept_charset" --> (none)
<!--#echo var="http_accept_encoding" --> gzip, deflate
<!--#echo var="http_accept_language" --> en-us
<!--#echo var="http_cache_control" --> (none)
<!--#echo var="http_connection" --> Keep-Alive
<!--#echo var="http_cookie" --> (none)
<!--#echo var="http_form" --> (none)
<!--#echo var="http_host" --> developer.evrsoft.com
<!--#echo var="http_referrer" --> (none)
<!--#echo var="http_ua_color" --> (none)
<!--#echo var="http_ua_cpu" --> (none)
<!--#echo var="http_ua_os" --> (none)
<!--#echo var="http_ua_pixels" --> (none)
<!--#echo var="http_user_agent" --> Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET CLR 2.0.50727)
<!--#echo var="http_x_forwarded_for" --> (none)
<!--#echo var="instance_id" --> (none)
<!--#echo var="last_modified" --> Tuesday, 28-Oct-2003 10:21:33 EST
<!--#echo var="page_count" --> (none)
<!--#echo var="path" --> /root/bin:/usr/local/admin/bin:/sbin:/usr/sbin...
:/usr/local/bin:/bin:/usr/bin:/usr/contrib/bin:/usr/X11/bin
<!--#echo var="path_info" --> (none)
<!--#echo var="path_translated" --> (none)
<!--#echo var="query_string" -->
<!--#echo var="query_string_unescaped" --> (none)
<!--#echo var="remote_addr" --> 135.245.10.4
<!--#echo var="remote_host" --> (none)
<!--#echo var="remote_ident" --> (none)
<!--#echo var="remote_port" --> 6195
<!--#echo var="remote_user" --> (none)
<!--#echo var="request_method" --> GET
<!--#echo var="request_uri" --> /~evrsoft/ ref_cgi_codes.shtml
<!--#echo var="script_filename" --> /~evrsoft/ ref_cgi_codes.shtml
<!--#echo var="script_name" --> /~evrsoft/ ref_cgi_codes.shtml
<!--#echo var="script_uri" --> http://developer.evrsoft.com/~evrsoft/ ref_cgi_codes.shtml
<!--#echo var="script_url" --> /~evrsoft/ ref_cgi_codes.shtml
<!--#echo var="server_admin" --> webmaster@evrsoft.com
<!--#echo var="server_addr" --> 63.247.76.37
<!--#echo var="server_name" --> developer.evrsoft.com
<!--#echo var="server_port" --> 80
<!--#echo var="server_protocol" --> HTTP/1.1
<!--#echo var="server_signature" -->
<!--#echo var="server_software" --> Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.6
<!--#echo var="total_hits" --> (none)
<!--#echo var="tz" --> (none)
<!--#echo var="unique_id" --> ZYMxJz-3TCIAAF3PPfoAAAAU
<!--#echo var="user_name" --> evrsoft
<!--#echo var="visp_domain" --> (none)
<!--#echo var="visp_remote_addr" --> (none)
<!--#echo var="visp_user" --> (none)