#!/usr/bin/perl read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-f0-9][a-f0-9])/pack("C", hex($1))/eig; $value =~ tr/+/ /; $value =~ s/%([a-f0-9][a-f0-9])/pack("C", hex($1))/eig; push (@slist, $name); $sinput{$name} = $value; } print "Content-type: text/html\n\n"; print "<html>\n"; print "<head>\n"; print "<title>Standard Input</title>\n"; print "</head>\n"; print "<body bgcolor=ffffff>\n"; if (@slist) { print "<h1>STDIN</h1>\n"; foreach $x (@slist) { print "$x=$sinput{$x}<br>\n"; } } print "</body>\n"; print "</html>\n"; exit;
This program is only good if you have an HTML form that points to this file. You could create an html file called /var/www/html/stdin.html that looked like this:
<html> <head> <title>STDIN Form</title> </head> <body bgcolor=ffffff> <h1>STDIN Form</h1> <form action=/cgi-bin/stdin.cgi method=post> <input type=text name=text1> <input type=text name=text2> <input type=text name=text3> <input type=submit> </form> </body> </html>
From this HTML you could then see what you had typed into the three text boxes when the CGI program ran.