#!/usr/bin/perl # readenv.cgi -- reads the environment, argv, and stdin # the first line of this script may have to be changed # if your system's Perl interpreter is not located in /usr/bin/perl # Written by P. Lutus 2/21/96 lutusp@arachnoid.com print "Content-type:text/plain\n\n"; @key = keys(%ENV); print ("Environment Entries:\n"); # there are always some of these! foreach $n (@key) { print ("\t$n=$ENV{$n}\n"); } if ($ARGV[0] ne "") { print ("Command-line Arguments:\n"); foreach $n (@ARGV) { print ("\t$n\n"); } } if($ENV{'CONTENT_LENGTH'} > 0) { print ("Stdin Contents:\n"); read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); $i = 0; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ s/~!/ ~!/g; # Stop people from using subshells to execute commands $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $value =~ s/~!/ ~!/g; # Stop people from using subshells to execute commands print "\t$name = $value\n"; } } exit;