procmail
[Top] [All Lists]

Re: N: For:Next

1999-12-12 14:11:23
Josh asked,

| Is it possible to set up a FOR NEXT type loop in a procmail recipe?

Not really.  One can set up a recursive INCLUDERC, but it is more like an
until-done loop.  Fortunately, (1) you can do it with the shell and (2)
splitmail will handle the looping for you, as Gary has already posted.

| Can mathmatical values be figured into variables?  (like
| size/150=numberofmsgs) after split -b150

Yes, but it's pretty darn nasty.

| :0:
| {
| :0w
| | $HOME/split -b150
| cat $HOME/xaa | mail -s 1 silver(_at_)mobile(_dot_)net
| cat xab | mail -s 2 silver(_at_)mobile(_dot_)net
| cat xac | mail -s 3 silver(_at_)mobile(_dot_)net
| cat xad | mail -s 4 silver(_at_)mobile(_dot_)net
| cat xae | mail -s 5 silver(_at_)mobile(_dot_)net
| rm $HOME/xa*
| }

First, why the extra layer of braces?

Second, you can't have more than one action on a recipe.  You can string
recipes with `A' flags or you can string unconditional recipes inside braces,
but here it is better (as again Gary has already said) to concatenate shell
commands with semicolons and backslashes.  So even without splitmail, you
could have done this:

 :0w:splitting$LOCKEXT # don't let two calls to split fight over x?? names
 | split -b150 ; for file in x?? ; \
   do mail -s $file silver(_at_)mobile(_dot_)net < $file ; done ; rm x??

But splitmail does the job better.

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