procmail
[Top] [All Lists]

Re: Folder size without a cat?

1996-03-17 11:17:04
Does anyone know of a way to check the size of a folder from inside
procmail without using a cat (in fact without using any external command)?
I would like to only have a rule operate if the folder that it would
eventually store the message in got to a certain (or larger) size.

I think the conventional wisdom is that you need an outside command.
I use wc and the scoring system.  Here's an example:

:0
Conditions for Omega stuff
{
    #Save the message in folder "Omega-l"
    :0 c:
    Omega-l

    ABSTRACTVAL=$LOGABSTRACT    #Don't log this ugliness
    LOGABSTRACT=no
    :0
    * !^X-Loop: omega-list(_at_)eskimo(_dot_)com
    {
        #Add this message to the digest accumulator
        :0 c:
        | formail -k -X From: -X Message-Id -X Date -X Subject >>$DIGESTIN

        #Check size of digest, and send it off if it's big enough
        :0
        * $ -$DIGSIZE^0
        * $ `wc -l <$DIGESTIN`^0
        | nice -10 send-digest $DIGESTIN
    }

    #Catch debris from recipes above
    :0
    /dev/null
    LOGABSTRACT=$ABSTRACTVAL    #Re-enable logging
}

You could just as easily test the size before saving the new message.

Cheers,
jimo(_at_)eskimo(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>