At 08:26 AM 9.7.2004 -0500, Bob Apthorpe wrote:
>On Mon, 6 Sep 2004 18:01:40 -0700 Rob Blomquist
<[EMAIL PROTECTED]> wrote:
>
>> On Wednesday 25 August 2004 5:46 am, Jack L. Stone wrote:
>> > At 10:31 PM 8.24.2004 -0700, Loren Wilton wrote:
>> > >> >   #!/bin/sh
>> > >> >   DEFFILES="/etc/mail/spamassassin/*.cf"
>> > >> >   GREPSTR="describe"
>> > >> >
>> > >> >   cat $DEFFILES | egrep ^$GREPSTR  \
>> > >> >
>> > >> >      | awk '{ print "echo `fgrep " $2 " /path/to/spamboxes.* \
>> > >> >      | wc -l` " $2 } ' | sort | uniq | tail +2 | sh | sort -rn
>> > >>
>> > >> $ ./spam-check
>> > >> ./spam-check: line 2: : command not found
>> > >> ./spam-check: line 3: : command not found
>> > >> ./spam-check: line 5: : command not found
>> 
>> I just got back to working on these problems, and a fresh mind seems to
have 
>> solved 90% of my problems. They were all due to the leading spaces in each 
>> line, remove them, and the script runs well with one caveat:
>> 
>> grep:  : No such file or directory
>> 
>> I can only figure that is erroring in 2 places, at
/etc/mail/spamassassin/*.cf 
>> which has 8 *.cf files in it. Or when looking for my spambox, which is 
>> located at /home/robbo/.Mail/SpamPile/cur/.
>> 
>> The file as it is now running, or not, is:
>> 
>> #! /bin/bash
>> DEFFILES="/etc/mail/spamassassin/*.cf"
>> GREPSTR="describe"
>> cat $DEFFILES | egrep ^$GREPSTR  \
>>     | awk '{ print "echo `fgrep " $2 "/home/robbo/.Mail/SpamPile/cur/ \
>>     | wc -l` " $2 } ' | sort | uniq | tail +2 | sh | sort -rn
>> #EOF
>
>Why not:
>
>#! /bin/bash
>DEFFILES="/etc/mail/spamassassin/*.cf"
>GREPSTR="describe"
>MAILFOLDER=/home/robbo/.Mail/SpamPile/cur
>egrep "^[      ]*$GREPSTR" $DEFFILES | \
>    | awk '{ print "echo `fgrep " $2 " $MAILFOLDER/* \ | wc -l` " $2 } ' \
>    | sort | uniq | tail +2 | sh | sort -rn
>#EOF
>
>Notes:
>
>'[     ]' is '[<space><tab>]' - useful for dealing with leading whitespace.
>If you really need to get rid of leading whitespace, pipe results of the
>egrep through "sed 's/^[       ]*//'" rather than deleting whitespace from
>the config files.
>
>There's a big difference between /home/robbo/.Mail/SpamPile/cur/ and
>/home/robbo/.Mail/SpamPile/cur/* and that's probably what's tripping you
>up.
>
>Running the code with 'sh -ax script.sh' helps with debugging shell scripts.
>
>hth,
>
>-- Bob
>

I posted this script a couple of weeks ago and as a bourne shell (csh)
script on FBSD with mbox-style mailboxes, it runs an analysis of about
30,000 emails in a few seconds (4-5?). I've never tried it as a bash. I say
mailboxes, but really all of the spams are copies in 3 single spam
collection boxes that I capture using a procmail recipe as they arrive. The
three boxes are yesterday, today (so far) and archive for the month (oh, #4
- an archive for each month). This allows me to watch for how the rule hits
are changing and those that are not hitting at all.

Also, you might consider running the script as one single line if you think
spaces are causing any problem -- shouldn't though.

Best regards,
Jack L. Stone,
Administrator

Sage American
http://www.sage-american.com
[EMAIL PROTECTED]

Reply via email to