printenv.cgi

The printenv script is included in the source for Apache, although it is not generally installed. I usually rename it to printenv.cgi, make it executable and put it in a protected subdirectory (usually using an .htaccess file) so it’s available for use in diagnosing web server environment issues. Here’s the text of the script for those who might find it useful:

#!/usr/bin/perl
##
##  printenv -- demo CGI program which just prints its environment
##
	
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\n|g;
    $val =~ s|"|\\"|g;
    print "${var}="${val}"\n";
}