Have you ever wondered whoes been visiting one of your web pages? Sure,
you can get the info from the server's log file, but it's a pain. Here
is a quick and dirty way. Your Web server must have Server Side Include
(SSI) enabled for this script to work.
Place the following near the end of an HTML source document. It can go anywhere but the end makes it unabtrusive. Additionally, the script's work will be done while your surfer is reading all that important stuff at the top of the page.
<!--#exec cgi="/cgi-bin/whocame.pl"-->
You would of course use your path and script name.
Create the following Perl script. (Feel free to cut and paste.)

#!/usr/bin/perl
# Script name whocame.pl
# Version 1.0 Created copyright 1996 by Urb LeJeune, lejeune@charm.net
# This script is designed to be called by a SSI in the form of:
# <!--#exec cgi="/cgi-bin/whocame.pl"-->
# It will write the user host name and browser type to a log file.
#
print "Content-type: text/plain\n\n";
#
# Generate a log file name in the form of:
# current path name + sub directory path + job name +
# source file name + ".log"
#
$pwd = `pwd`; # Get the current path
chop($pwd); # Remove end of line character
$html = $ENV{'DOCUMENT_NAME'}; # What is the name of the calling document?
($html) = split(/\./,$html); # Remove "." and extension from $html
$data_dir = "data"; # Where does log file go?
$jobname = "ATS"; # Application name
$logfile = $pwd . "/" . $data_dir . "/" . $jobname . "-" . $html . ".log";
# Open the log file and write the remote host and user's browser type
open (OUTPUT,">>$logfile");
print OUTPUT "Remote Host: $ENV{'REMOTE_HOST'}\n";
print OUTPUT "Browser Type: $ENV{'HTTP_USER_AGENT'}\n\n";
close (OUTPUT);
Return 1; # Script completed successfully.

As an example, if the SSI is inserted in index.html, you assign the job
name "MY-STUFF" to $jobname above, and your cgi director is cgi-bin,
you will have a log file name MY-STUFF-index.log in directory
cgi-bin/data. If you place the SSI in several file you will have a
different directory for each HTML document. whatshot.html will procude
MY-STUFF-whatshot.log, etc.
An output from an execition might look like:
Remote Host: itacom.digex.net Browser Type: Mozilla/2.02 (Win16; I)You can view the log files -- assuming your using Unix and have used a $jobname of "MY-STUFF" -- by entering:
more MY-STUFF*
at the Unix command line prompt.
Stay tuned for more free stuff.

![]() | up to date with our "free stuff", special offers, and other goodies. |
![]() | Please sign our
self-updating guestbook How about some free stuff from ATS? |
Please send our
crotchety Webmaster some mail.


Copyright ©1996 America's Town Square
15 Hunter Drive
Tuckerton, NJ 08087
(609) 294-0320
[an error occurred while processing this directive]