procmail
[Top] [All Lists]

Re: Scanning IMAP mail (first solution)

2009-11-17 18:34:53
Somebody asked me to not post to the forum in html, and I didn't get any 
feedback on this.
So I reformatted this to plain text.

LuKreme,

Did you try this?  Any feedback?  I'm curious to know if this is much of an 
improvement in speed?

Any feedback from anybody else?

===================================
$ :| procmail -pm LuKreme.rc
        
        2 .httpd-users.2009-11
        1 .mailman-users.2009-11
        5 .mythtv-users.2009-11
        1 .postfix-users.2009-11
        2 .procmail.2009-11
        11 Total
          Folder: /dev/null       1

===================================
$ cat LuKreme.rc 

        NL="
        "
        LOGFILE=/dev/stderr
        
        CUR_LIST=`/usr/bin/find Maildir/ -regex
        '.*/cur/.*,'|/usr/bin/gawk -F/ '{print $2}'`
        LISTS=`uniq <<< "$CUR_LIST"`
        
        :0
        * 1^1 LISTS ?? ^.*$
        { COUNT = $= }
        
        FOR_INDEX = 1                   # required
        FOR_MAXIMUM = $COUNT            # required
        FOR_PROCEDURE='tally.rc'        # required
        INCLUDERC='swa-for_loop.rc'
        
        :0
        * 1^1 CUR_LIST ?? ^.*$
        { TALLY="$TALLY$NL$= Total" }
        
        LOG="$TALLY
        "
        
        :0 
        /dev/null

===================================
$ cat tally.rc
        
        LIST=`/bin/sed -ne ${FOR_INDEX}p <<< "$LISTS"`
        
        :0
        *$ 1^1 CUR_LIST ?? $LIST
        { TALLY="$TALLY$NL$= $LIST" }
        
===================================
$ cat swa-for_loop.rc 
        
        # swa-for_loop.rc
        # Copyright 2009, SwaJime's Cove
        # Author: John W. Simpson
        # Version: 1.0.0
        # Date: 30-Oct-2009
        #
        # Recursive for loop
        #   Maybe I'm blind?  Procmail doesn't seem to have a "for
        loop" (or while,until,goto,gosub,loop,etc...)
        #   This procedure uses recursion to simulate this bash for
        loop:
        # 
        # Example usage: 
        #
        # # for (( FOR_INDEX = 0; FOR_INDEX <= 9; do procedure.rc; done
        # FOR_INDEX = 0                   # required
        # FOR_MAXIMUM = 9                 # required
        # FOR_PROCEDURE='procedure.rc'    # required
        # INCLUDERC='swa-for_loop.rc'
        #
        
        # LOG="   FOR $FOR_INDEX OF $FOR_MAXIMUM; doing $FOR_PROCEDURE
        $NL"
        
        INCLUDERC=$FOR_PROCEDURE
        :0
        *$ $FOR_INDEX^0
        * 1^0
        {
           FOR_INDEX=$=
           :0
           * 1^0
           *$ $FOR_MAXIMUM^0
           *$ -$FOR_INDEX^0
           {
              INCLUDERC = $_
           }
        }

-- 
JW Simpson <john(_at_)swajime(_dot_)com>
SwaJime's Cove℠

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail