procmail
[Top] [All Lists]

Re: Recipe setup...

1997-11-29 03:15:16
On Sat, 29 Nov 1997, Jason Lixfeld wrote:
:0 D
*
{
SUB=`formail -x Subject: | awk '{print $1}' | sed s/:/""/`
}

Is there a condition to be satisfied above? If not you don't need to
use the * to start a test of a condition.

:0 c
* ^Subject:.*\<$SUB\>
/home/admin/mail/$SUB 

procmail: No match on "^Subject:.*\<$SUB }"
procmail: Locking "/var/spool/mail/admin.lock"
procmail: Error while writing to "/var/spool/mail/_rv2Gsuntzu.ad"

Could you be more specific about what sort of strings there are to be
matched? If you are just trying to find mail Subject: "BSDI:"? or is
there a set of possible keywords that get filed? When I run your
awk\sed command it just reduces a string 'STRING: whatever" to
"STRING".

To get the contents of a subject field into a variable use:
        SUBJECT=`formail -zx"Subject:"`
You can manipulate the contents of the var a number of different ways.
I think you could so the same thing your awk\sed command does with:
        SUBLEADER=`formail -zx"Subject:|cut -d: -f1`
You can then test the var in a recipe condition line for a certain
leader, eg. TEST:
        * $ SUBLEADER ?? '^TEST$'

To find a particular subject-leader, eg. "TEST:", and file a copy of
that mail in the file ~/home/mail/TEST" while letting the original
continue through procmail for delivery elsewhere, do this: 
(You don't need to capture the subject into a variable for this.)
( [^     ] contains a carat, a tab, and a space.)
        :0 cD:
        * ^Subject:[^    ]*TEST:
        /$HOME/mail/TEST

To file mail by a variety of fixed subject LEADERS:
        :0 cD:
        * ^Subject:[^    ]*(LEADER1|LEADER2|LEADER3|LEADER4):
        * ^Subject:[^    ]*\/(LEADER1|LEADER2|LEADER3|LEADER4)
        /$HOME/mail/$MATCH

Condition 1 above first checks for a leading word in the subject
matching any of the leaders followed by a colon. Condition 2 is less
picky, but captures the leader into a special var named MATCH without
capturing anything else, like the colon. You could use only the second
condition, but it could get LEADER without the colon.

With some more specifics I might be able to suggest something
particularly suited to your specific goals.

David Hunt


The above, broken part is where I try to save the message to the file
called the variable which was created above (procmail: Assigning
"SUB=BSDI").  Technically, I should be able to assign the directory
by some method similar to what is written in the :0 c portion of the
recipe.

Anyone know how I can do that?!  Does everyone see what I'm trying to do?

On Fri, 28 Nov 1997, no-mailbox wrote:

On Fri, 28 Nov 1997, Jason Lixfeld wrote:

Jason,
I think the problem is the first recipe. You cant set  avariable in an
action line like you did because it gets executed in a subshell. You
have to use curly-braces and drop the flags. Your first recipe
modified:

## IE: message comes in with subject of "BSDI: TEST" >
## writes subject to $DETAILS variable: BSDI
:0 D
*
{  DETAILS=`formail -x Subject: | awk '{print $1}' | sed s/:/" "/`  }

I dont' know awk and sed well, but it seems to simply reduce the
subject line to the first word, minus the colon. You could use this: 
:0 D
* ^Subject:[  ]*BSDI: TEST
{  DETAILS=BSDI }

Of course, that only demonstrates the job. You'd have to customize for
your needs. There are other ways to do this, but I'd have to
understand the needs better.

The next recipe copies to a file named BSDI. You need to use a fulll
path, and procmail does not recognize tilde. I'm guessing ~admin is a
typo for ~/admin so then the recipe is:
## finds messages with BSDI in subject and copies to ~admin/mail/BSDI
:0 c
* ^Subject:.*\<$DETAILS\>
$HOME/admin/mail/$DETAILS

Good Luck!
David Hunt

:0 Ah
## Mhonarc then archives all new mail within /home/admin/mail/BSDI file,
#chmods (not proprietary to procmail), then nukes the old box BSDI so when
#mhonarc runs again, all it has to do is archive the newest message, and
#not all of them.
| mhonarc -outdir /webhome/server/htdocs/archive /home/admin/mail/$DETAIL\
; chmod 755 /webhome/server/htdocs/archive/* ; rm -rf \
/home/admin/mail/$DETAIL

It doesn't work.  I'm not sure if procmail can accept variables or not,
but anyone who can understand the above recipe, please see if their is
anything wrong with it.  BTW:  The commnets that are added into the
procmailrc were added for this email only.

Thanks in advance!

Regards,

   Jason A. Lixfeld

.oO
System Administrator [Level 4]
TUCOWS Interactive Inc. o/a Internet Direct
Moo... "A Different Kind of Internet Company"
Oo.

jlixfeld(_at_)idirect(_dot_)ca  \
                 \  jlixfeld(_at_)idirect(_dot_)com





Regards,

      Jason A. Lixfeld

.oO
System Administrator [Level 4]
TUCOWS Interactive Inc. o/a Internet Direct
Moo... "A Different Kind of Internet Company"
Oo.

jlixfeld(_at_)idirect(_dot_)ca  \
                    \  jlixfeld(_at_)idirect(_dot_)com



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