procmail
[Top] [All Lists]

Re: (no subject)

2005-06-17 01:43:27
On Thu, Jun 16, 2005 at 06:14:06PM -0400, Alex Vandiver wrote:

  I'm trying to programmatically include an entire directory of procmail
files.  That is, I have:

procmailrc.d/
  rule-1
  rule-2
  rule-3

..with each rule file containing a few procmail rules.  I'm trying to
write a procmail file that includes all of these rule files.  I've seen
mentions of "recursive INCLUDERC", but I'm not clear on how to do this,
and if it is actually the solution to the problem in question.

There are several ways to do this.  I'm doing this at present myself.
Ways without recursion include having cron list the dir and create a
line of INCLUDERC instructions; or manually constructing a list and
placing it in a file.

If you want procmail to find the files, then you're going to need
to recurse through the list, yes, nad you're going to have to
construct a list, probably with a shell call to ls.  You can do it
without the ls fork if you have a naming scheme that procmail can
look for.  You could just number the files -- similar to what you
have above -- and set up a recursive counter in procmail.  But then
your names might not be very discriptive, which might or might not
be a problem for your logs or your own memory.  You could have an
env var inside the file state what the file is.  I do a combination
of these things.

In any case, suppose you have a list of files and you have somehow fed
the contents to procmail, whether by an ls fork, an assignment 
statement (perhaps updated by cron), or whatever.  Suppose it looks
like this:

  9:49am [~/Mail/foo] 262[0]> ls -1
 rule-1
 rule-2
 rule-3


Here's one way:


 ####################  start test.rc  ####################

 :0
 * LIST ?? ^^()^^
 { NEXTONE   LIST = `ls foo` }  # happens on first run only

 :0
 * $ LIST ?? ^$\NEXTONE^?\/.+
 { NEXTONE = $MATCH   INCLUDERC = foo/$NEXTONE  SWITCHRC = $_ }

 #####################  end test.rc  #####################



Okay, I've marked three of the lines below with "=>" in front to draw your
attention to them:

   10:06am [~/Mail] 296[0]> procmail -m DEFAULT=/dev/null VERBOSE=y test.rc < 
/dev/null
  procmail: [5742] Fri Jun 17 10:06:33 2005
  procmail: Assigning "MAILDIR=."
  procmail: Rcfile: "test.rc"
  procmail: Match on "^^()^^"
  procmail: Assigning "MATCH"
  procmail: Executing "ls,foo"
  procmail: Assigning "LIST=rule-1
  rule-2
  rule-3"
  procmail: Assigning "MATCH="
  procmail: Matched "rule-1"
  procmail: Match on "^()^?\/.+"
=>procmail: Assigning "INCLUDERC=foo/rule-1"
  procmail: Assigning "SWITCHRC=test.rc"
  procmail: No match on "^^()^^"
  procmail: Assigning "MATCH="
  procmail: Matched "rule-2"
  procmail: Match on "^()rule-1^?\/.+"
=>procmail: Assigning "INCLUDERC=foo/rule-2"
  procmail: Assigning "SWITCHRC=test.rc"
  procmail: No match on "^^()^^"
  procmail: Assigning "MATCH="
  procmail: Matched "rule-3"
  procmail: Match on "^()rule-2^?\/.+"
=>procmail: Assigning "INCLUDERC=foo/rule-3"
  procmail: Assigning "SWITCHRC=test.rc"
  procmail: No match on "^^()^^"
  procmail: No match on "^()rule-3^?\/.+"
  procmail: Assigning "LASTFOLDER=/dev/null"
  procmail: Opening "/dev/null"
    Folder: /dev/null                                                           0
  
-- 
dman

____________________________________________________________
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

<Prev in Thread] Current Thread [Next in Thread>
  • (no subject), Alex Vandiver
    • Re: (no subject), Dallman Ross <=