20090909 printenvcgi - plembo/onemoretech GitHub Wiki

title: printenv.cgi link: https://onemoretech.wordpress.com/2009/09/09/printenvcgi/ author: lembobro description: post_id: 254 created: 2009/09/09 14:11:32 created_gmt: 2009/09/09 14:11:32 comment_status: open post_name: printenvcgi status: publish post_type: post

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";
}

Copyright 2004-2019 Phil Lembo