CGI Environment Variables
2002-08-11 10:05:02
Category: perl:cgi
Description: Explination of the environment variables that PERL handles and uses.
Author: Snap
Viewed: 2543
Rating: (5 votes)


#!/usr/bin/perl
print "Content text:html/text\n\n";
 
##########################################
#                                        #
#                                        #
#   Written by Snap                      #
#           (iam@someoneshouse.com)      #
#                                        #
#   For Metalshell                       #
#       http://www.metalshell.com        #
#                                        #
#  This is a simple script, more of an   #
#  example of all the possible           #
#  environment variables that can be     #
#  used and handled by PERL.             #
#                                        #
##########################################
 
 
print<<STOP
 
<html>
<body>
 
 
Your Gateway Interface Type (Usually Common Gateway Interface or CGI)<BR>
$ENV{GATEWAY_INTERFACE}<br><br>
 
Addresses that your Webserver Accepts<br>
$ENV{HTTP_ACCEPT}<br><br>
 
Your HTTP Connection Type<br>
$ENV{HTTP_CONNECTION}<br><br>
 
The Host Name<br>
$ENV{HTTP_HOST}<br><br>
 
Type of browser you're using<br>
$ENV{HTTP_USER_AGENT}<br><br>
 
Remote User's Host Name<br>
$ENV{REMOTE_HOST}<br><br>
 
Remote User's IP Address<br>
$ENV{REMOTE_ADDR}<br><br>
 
Remote User's Connecting Port<br>
$ENV{REMOTE_PORT}<br><br>
 
HTTP Request Method (Generally GET)<br>
$ENV{REQUEST_METHOD}<br><br>
 
The Scripts Filename<br>
$ENV{SCRIPT_FILENAME}<br><br>
 
The Name of the Script<br>
$ENV{SCRIPT_NAME}<br><br>
 
 
Type of Web server used for hosting on server<br>
$ENV{SERVER_SOFTWARE}<br><br>
 
Server Admin's E-mail (or Identification)<br>
$ENV{SERVER_ADMIN}<br><br>
 
Port the server is accepting HTTP requests on<br>
$ENV{SERVER_PORT}<br><br>
 
Protocol The server is using<br>
$ENV{SERVER_PROTOCOL}<br><br>
 
The Query String, passed by other scripts or HTTP<br>
$ENV{QUERY_STRING}<br><br>
 
General Path Information<br>
$ENV{PATH_INFO}<br><br>
 
The Translated Path<br>
$ENV{PATH_TRANSLATED}<br><br>
 
What type of content was passed<br>
$ENV{CONTENT_TYPE}<br><br>
 
Length of the content<br>
$ENV{CONTENT_LENGTH}<br><br>
 
Server's Domain Name<br>
$ENV{SERVER_NAME}<br><br>
 
<\/body>
<\/html>
STOP