Perl stuff

Old, probably badly written and not maintained! You have been warned.

cgi-bin bits

env.pl

- Prints out webserver variables available to your script

#!/bin/perl  - or whatever your path to perl is
# env.pl
# This script dumps the environment variables in HTML format
 
use strict;
use warnings;
$|=1;
 
print "Content-type:text/html\n\n";
 
foreach my $var (sort keys %ENV) {
    print $var . "=" . $ENV{$var} . "<br>\n";
}

about.pl

#!/usr/sbin/perl
use strict;
use warnings;
$now = localtime ;
print "Content-type: text/html", "\n\n";
print "<HTML>", "\n";
print "<HEAD><TITLE>About this server</TITLE></HEAD>", "\n";
print "<BODY><H1>About this server</H1>", "\n";
print "<HR><PRE>";
 
print "Today is                 ", $now, "<BR>", "\n";
print "Server Name:             ", $ENV{'SERVER_NAME'}, "<BR>", "\n";
print "Running on Port:         ", $ENV{'SERVER_PORT'}, "<BR>", "\n";
print "Server Software:         ", $ENV{'SERVER_SOFTWARE'}, "<BR>", "\n";
print "Server Protocol:         ", $ENV{'SERVER_PROTOCOL'}, "<BR>", "\n";
print "CGI Revision:            ", $ENV{'GATEWAY_INTERFACE'}, "<BR>", "\n\n";
print "You are ", $ENV{'REMOTE_ADDR'}, "<BR>", "\n";
print "Your machine is ", $ENV{REMOTE_HOST}, "<BR>", "\n";
print "<HR></PRE>", "\n";
print "</BODY></HTML>", "\n";
 
exit (0)

my-ip.pl

#!/usr/bin/perl
 
#developed from original script by Andrew Stringer 09/10/2002 onwards.
 
use strict;
use warnings;
 
#Set to ip passed from apache or if undefined, use Google.
my $remotehost=$ENV{'REMOTE_ADDR'} || '8.8.8.8';
 
my $ENVIRO=`env` ;
 
print "Content-type:text/html\n\n";
 
print <<ENDOFTEXT1;
<html>
<head>
<title>My ip</title>
</head>
 
<body>
Your ipaddress is:- $remotehost
<br><br>
 
 
ENDOFTEXT1
 
#print $ENVIRO ;
 
my @traceroute=`/usr/bin/tcptraceroute $remotehost`;
 
print "@traceroute \n";
# Again, you can print (or do whatever with) the answer:
 
my $i;
foreach $i (@traceroute) {
# Here you can print or analize each line of the answer
print "$i\n<br>";
}
 
 
print <<ENDOFTEXT2;
 
End of trace.
 
</body>
</html>
ENDOFTEXT2
 
exit (0);
 
perl/start.txt · Last modified: 13/09/2023 17:11 by andrew