Gossamer Forum
Home : General : Perl Programming :

Getting hits

Quote Reply
Getting hits
I know that this script is probably a security risk because I am using the system command but what I am trying to do is get the hits of a webpage. They read from the access logs and puts the output into a table. My problem is that it isn't getting the correct number. Each access file is the name of the domain.

system("ls /var/log/apache/access/* > found");

open (INF, "found");
@grok = <INF>;
close(INF);

foreach $i (@grok) {
$i =~ s/.*[\/\\](.*)/$1/;
$count = system("grep -c GET $i");
print "<tr><td><font size=1>$i</font></td><td><font size=1>$count</font></td></tr>";
}

I know that I am only grepping the file when I should be grepping the path and the file but I couldn't get it to all work together. Could somebody see what I am doing wrong. Somebody said that you couldn't put the count from a grep into a variable. Any ideas? I can't use modules as I am in a class learning basic perl and I don't want to get to far ahead with modules. So if possible I would like to use the system command.
Subject Author Views Date
Thread Getting hits constantm 5619 Jun 26, 2002, 7:19 AM
Thread Re: [constantm] Getting hits
Paul 5460 Jun 26, 2002, 7:22 AM
Thread Re: [Paul] Getting hits
constantm 5458 Jun 26, 2002, 8:03 AM
Thread Re: [constantm] Getting hits
constantm 5483 Jun 26, 2002, 8:11 AM
Thread Re: [constantm] Getting hits
Paul 5501 Jun 26, 2002, 8:22 AM
Thread Re: [Paul] Getting hits
constantm 5461 Jun 26, 2002, 8:47 AM
Thread Re: [constantm] Getting hits
Paul 5487 Jun 26, 2002, 8:59 AM
Thread Re: [Paul] Getting hits
constantm 5445 Jun 26, 2002, 10:14 AM
Thread Re: [constantm] Getting hits
Paul 5450 Jun 26, 2002, 10:23 AM
Post Re: [Paul] Getting hits
oldmoney 5417 Jun 28, 2002, 5:27 AM