Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP tracing 1

Status
Not open for further replies.

snookmz

Programmer
Apr 17, 2001
46
AU
G'day everyone

In the past i have used a program (im sure you're all familiar with) 'web-position gold', which was able to track where the hits to my site originated from.. i.e. which search engines they clicked through...

Now WPG was using some javascript at the bottom of each html page to log all this.. I was wondering whether there was a way to do with with perl by crunching the log files generated on my IIS server..

any ideas??? Thanks in advance /-------------------------------------
| I always have been, and always will |
| be, a newbie :) |
\-------------------------------------
 
absolutely,
philosophically speaking (typing),.....


while (reading the log file)
{
parse each line;
catch each HTTP_REFERER;
write it to a report or file;
}

It's hard to give much more detail without seeing the log file.

HTH


keep the rudder amid ship and beware the odd typo
 
Thanks for your help goBoating

Im assuming that this HTTP_REFERRER variable can only be used while running a script from an HTML form.. Because it would need to grab browser variables that just wouldn't exsist with an IP in a server log file..

would i be correct in this assumption???

thanks again for your help :) /-------------------------------------
| I always have been, and always will |
| be, a newbie :) |
\-------------------------------------
 
Sorry, I have slightly muddied the waters by using 'HTTP_REFERER' as the name for that piece of information. That name (HTTP_REFERER) is normally associated with parsing the HTTP request header which would be done in a piece of CGI. However, a similar piece of information, with a different name (.... maybe remote host?) should be available to you by reading/parsing your web logs.

My Apache access_log file has the 'calling remote host' as the first element in each line followed by a dash, '-'. So,....

#!/usr/local/bin/perl
open(IPF,&quot;</httpd/logs/access_log&quot;) or die &quot;Failed to open log file, $!\n&quot;;
while (<IPF>)
{
# split on the dashes
@elements = split(/-/,$_);
# first element in the line
$remote_host = $elements[0];
# do whatever you want with the remote host info.
}
close IPF;


This could be more concise, but, I left it a little verbose for clarity.

HTH




keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top