Re: [SLUG] bash woes - my turn

From: Mike Branda (mike@wackyworld.tv)
Date: Wed Aug 03 2005 - 18:49:01 EDT


On Wed, 2005-08-03 at 17:13 -0400, Eben King wrote:
> On Wed, 3 Aug 2005, Mike Branda wrote:
>
> > Well our web host uses analog to give stats but it doesn't do unique
> > visitors. I found a project called "visitors" that does and also
> > outputs visio style traffic flowcharts. However, they only give me real
> > apache log files for 5 days. After that all you get is what analog
> > outputs for up to 2 years I think. So I've started cat-ing the
> > access.log.0 (the 1 day old logrotate file) to the end of a cumulative
> > file so I can use visitors.
>
> Isn't that cumulative file going to grow without bound?
>

As of right now what happens is that it is moved at 6 AM on the first of
each month from cumulativeaccess.log to
cumulativeaccess.log.2005-08-01.gz with the appropriate date of course
and a touch creates a new cumulativeaccess.log. The newly created file
doesn't get populated until the next day after the host writes it's
access.log.0 and another script cat's that.

>
> Try
> > not to laugh at this too hard as it's only my second attempt at a bash
> > script. :^) I built in an else and elif to handle if one of the files
> > is missing somehow. So the deal is that $file1 is now multiple files.
> > also keep in mind that evolution is wrapping the long lines.
>
> > #!/bin/bash
> >
> > home="/home/wws1"
> > logdir="$home/cumulativelog"
> > file1="access.log.*.gz"
>
> I hope you aren't relying on some program's behavior of "when presented with
> multiple files e.g. 'access.jan.log.gz access.feb.log.gz access.mar.log.gz'
> only deal with the first one" (and the fact that $file1 isn't in ""),
> because that'll break as soon as somebody touch(1)es a previous month's
> file. I like Bill Glidden's idea of using date(1).
>
>

I use date when the file is created. And actually, I want it to deal with all
the files. That's the point and problem. It worked fine until 2 days ago
but now more than one file exists. I was expecting the file1="access.log.*.gz"
to give me output of all the gzipped per month files. It choked this month
because there's more than one. How do I get it to decompress/read them all?

The error is:

./createReports.sh: [: /home/wws1/cumulativelog/access.log.2005-08-01.gz: binary operator expected

I'll try your other suggestions to clean up the rest.

Mike Branda Jr.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:41:32 EDT