Script for automating web access count

Script for automating web access count

Post by Pankaj M Saxe » Sat, 24 Jun 1995 04:00:00


        I am trying to put an access counter on my web page. Not having CGI
on my server, I would like to use the server logs to get the access
information I need. I am using WWWSTAT for the purpose.

        I would like to automate the following task through a shell script:

1. go to the directory /usr/local/etc/httpd/logs
2. there are several files in this directory that are of the form:
                        xxxxx is a date, like Jun22
                        yy:yy:yy is the time, like 23:46:45
                        gz indicates that the files are gzip'ed
3. pick the file that has the most recent date and time on it and copy it
   to my home directory, i.e., /homes/home1/pankaj
4. In my home directory, the script should gunzip the file to a different
   name - call it "a_log".
5. After decompressing the file to "a_log", run the following command:
        wwwstat -olur -n '^/~pankaj/' a_log > log.html
6. Then, move the file generated by the previous command (log.html) to the
   directory: /homes/home1/pankaj/public_html
7. At the same time, also append the contents of the file "log.html" to
   another file called "" also in the same directory.
8. Next, change the mode of the file "log.html" in the "public_html"
   directory to a+r

        I wonder if anyone has a script that does these things. What I am
trying to do is to generate a log of accesses to my web page and make it
available as an html document. I do not have CGI, so I am forced to work
with the server logs. I use the program WWWSTAT (version 1.0) to generate
the html document from the access logs for the server.

        I am on a unix system (RS/6000 running AIX 4.1.2). I generally use
ksh for my login shell, so I would prefer to use this shell for the script.

        I would appreciate any help I can get in writing this script. Also,
if anyone has written a script that does these things (or something that
can be modified to do the stuff I described), I would appreciate a copy.