Previous Topic: Extract HTTP Headers Using NSAPINext Topic: Extract HTTP Headers Using ASP


Extract HTTP Headers Using PERL

Accessing environmental variables from the Practical Extraction and Report Language (PERL) is a standard practice. The following script is a PERL version of the shell script TEST.SH that returns the variables to the browser:

#!/usr/win32/perl117
# Example Test Program To Echo Back Default
# Web Agent Headers from a CGI environment
#
# First put out a valid CGI Header
print “Content-Type: text/html\n\n”;
# Now print out the standard HTML document tags
print “<HTML>”;
print “<HEAD><TITLE> Test Web Agent Headers </TITLE></HEAD>”;
print “<BODY BGCOLOR=#ffffff>”;
print “<H1> Test Web Agent Headers </H1>”;
print “HTTP_SM_USER: $ENV{‘HTTP_SM_USER‘} <BR>”;
print “HTTP_SM_AUTHTYPE: $ENV{‘HTTP_SM_AUTHTYPE‘} <BR>”;
print “HTTP_SM_SESSIONID: $ENV{‘HTTP_SM_SESSIONID‘} <BR>”;
# Now end the HTML file output
print “</BODY>”;
print “</HTML>”;

The following PERL script returns all the environment variables to the browser, not just SiteMinder variables.

#!/export/home/iplanet/server4/install/perl
print "content-type: text/html\n\n";

print "<HTML>\n";

print "<HEAD>\n";
print "<TITLE>echo cgi env. vars.</TITLE>\n";
print "<H2>Echo CGI Environment Variables</H2>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "<HR>\n";
print "<H3>Environment Variables</H3>\n";
print "<UL>\n";
foreach $key (keys %ENV) {
print "<LI>$key = $ENV{$key}\n";
}
print "</UL>\n";
print "</BODY>\n";