On Wed, 2005-08-03 at 19:26 -0400, Eben King wrote:
> On Wed, 3 Aug 2005, Mike Branda wrote:
>
> > On Wed, 2005-08-03 at 17:13 -0400, Eben King wrote:
> > > On Wed, 3 Aug 2005, Mike Branda wrote:
> > >
> > > > #!/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.
>
> Yeah, what gets run is something like
>
> file1="access.log.jul.gz access.log.jun.gz"
>
> No error there. But later on when you call
>
> (gunzip -c $logdir/$file1 && cat $logdir/$file2) | $commanda
>
> what gets run is
>
> (gunzip -c /home/wws1/cumulativelog/access.log.jul.gz access.log.jun.gz && ...
>
> So that won't work. Oh, and $home is defined (contrary to my comment), but
ahh...I wasn't expecting it to expand that way....oops.
> IMO the similarity of "home" to "HOME" invites confusion. Maybe call it
> "wws_home" instead?
>
agreed. I'll change that too.
> > 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?
>
> for file in "$logdir"/access.log.*.gz ; do
> # do stuff with $file
> done
>
I figured it had to be some form of "for this ; do". I just wasn't sure
how to tie it in to the part with
(gunzip -c $logdir/$file1 && cat $logdir/$file2) | $commanda
but now that you gave me the idea of storing that info instead of
decompressing twice for both commands, it's got to be re-written anyway.
Thank you for that idea.
> They'll be dealt with in dictionary (not chronological) order. Is that OK?
>
yeah...visitors doesn't care. It doesn't seem to generate the report
until after it get's all it's input. There also seems to be code that
discriminates double entries. i.e. the same entry exists in both
access.log and access.log.foo.gz with the same timestamps and data.
> > The error is:
> >
> > ./createReports.sh: [: /home/wws1/cumulativelog/access.log.2005-08-01.gz: binary operator expected
>
> Hmm, doesn't say what line. That would help.
>
I agree but that's every last inch of output I get. crappy. Although
now that you mention it, as I was originally writing/debugging this all
the errors did print a line number. I guess that's maybe because It's
not a bash syntax error but output from visitors complaining about the 2
file names in the expansion?
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:40 EDT