procmail
[Top] [All Lists]

Re: procmail Digest, Vol 94, Issue 21

2010-11-26 11:36:43
Thank you so much for your reply. I have to explain in detail what I am 
actually targeting. I am new to prpcmail, but in the current mail server 
(MDaemon)
The way the content filter work is like this:

If the To header contains support(_at_)domain(_dot_)com then a program is run. 
This program will query the company's database to see if the sender is a client 
or not. If is a client, the script will then tag the subject with the account 
manager's id and return a particular exitcode. 

Now the content filter will now check the exitcode of the program and use the 
new subject to deliver the mail. If a different exit code is return by the 
program, then a different action is taken which is to delete the message and 
not allow it pass through.

This is the same thing I want to do.

Right now, the procmail is able to run the script and the script too is able to 
query the database and tag the subject header, but how to feed this back to 
procmail and procmail too should check the exit code and take the necessary 
actions on it.

Attach is the script I worked on. Unfortunatly, I don't have the procmailrc on 
this pc so I can't send it right now.

I will also go through what you sent and try to work some thing out though am 
confuse.

Thanks


--- On Thu, 11/25/10, procmail-request(_at_)lists(_dot_)RWTH-Aachen(_dot_)de 
<procmail-request(_at_)lists(_dot_)RWTH-Aachen(_dot_)de> wrote:

From: procmail-request(_at_)lists(_dot_)RWTH-Aachen(_dot_)de 
<procmail-request(_at_)lists(_dot_)RWTH-Aachen(_dot_)de>
Subject: procmail Digest, Vol 94, Issue 21
To: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
Date: Thursday, November 25, 2010, 11:00 PM

Send procmail mailing list submissions to
    procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de

To subscribe or unsubscribe via the World Wide Web, visit
    http://mailman.rwth-aachen.de/mailman/listinfo/procmail
or, via email, send a message with subject or body 'help' to
    procmail-request(_at_)lists(_dot_)RWTH-Aachen(_dot_)de

You can reach the person managing the list at
    procmail-owner(_at_)lists(_dot_)RWTH-Aachen(_dot_)de

When replying, please edit your Subject line so it is more specific
than "Re: Contents of procmail digest..."


Today's Topics:

   1. Exitcode (Emmanuel Buamah)
   2. Re: Exitcode (Professional Software Engineering)


----------------------------------------------------------------------

Message: 1
Date: Thu, 25 Nov 2010 13:35:39 -0800 (PST)
From: Emmanuel Buamah <wasanzy(_at_)yahoo(_dot_)com>
To: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
Subject: Exitcode
Message-ID: 
<319327(_dot_)33843(_dot_)qm(_at_)web120503(_dot_)mail(_dot_)ne1(_dot_)yahoo(_dot_)com>
Content-Type: text/plain; charset="iso-8859-1"

Hi All,

I have written a script that is being invoked from procmail. Now I want 
procmail to wait untill the program finishes and check it's exitcode.

My question is, how do I check the exit code of the script and take an action 
on it?

Regards

Emanuel



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mailman.rwth-aachen.de/pipermail/procmail/attachments/20101125/51623a3f/attachment-0001.html>

------------------------------

Message: 2
Date: Thu, 25 Nov 2010 14:23:20 -0800
From: PSE-L(_at_)mail(_dot_)professional(_dot_)org (Professional Software 
Engineering)
To: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
Subject: Re: Exitcode
Message-ID: 
<201011252223(_dot_)oAPMNYl0006395(_at_)trei(_dot_)professional(_dot_)org>
Content-Type: text/plain; charset=us-ascii; format=flowed

At 13:35 2010-11-25, Emmanuel Buamah wrote:
My question is, how do I check the exit code of the script and take 
an action on it?

As a condition, or as a filter?  If as a filter, do you only need 
true/false granularity, or to act upon a specific value?

:0fw
| some_script

Would filter the message and wait for the exit code - if it isn't 0 
(success), then it treats the message as if the recipe hadn't been 
invoked and reverts to the original (unfiltered) message.

:0
* ? some_script
mailbox

Would pump the headers of the message (unless you added hb or b to 
the flags line, or H or B to the condition line) into the script and 
use the exit code as an inverted true/false (exitcode = 0 = true, any 
nonzero, false) for evaluating the condition.

If you invoke a pipeline this way, such as:

* ? grep username | grep something

the exitcode which is evaluated is the one returned by the last 
program in the pipeline.


If you want the actual value to subsequently evaluate, then:

DUMMYVAR=`some_program args`
SOME_PROGRAM_EXITCODE=$?

Note that this is outside of a recipe (though it could be within a 
braced section).

This is not to be confused for condition lines which may have $? at 
the beginning, which would evaluate shell variables and examine the 
return value (but isn't an assignment).  You'd want to assign the 
value to a variable so that you could evaluate it in a condition 
without the exitcode variable being evaluated as a pair of 
flags.  You can use scoring to do math for checking whether the 
variable exceeds a certain value.

:0
* -25^0
* $ $SOME_PROGRAM_EXITCODE^0
mailbox

Would evaluate as true if the saved exitcode exceeded 25.

If you just want to match a specific value:

:0
* SOME_PROGRAM_EXITCODE ?? ^25$
mailbox

If you wanted to match for 25 exactly (or ^^25^^ would work).

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the list.



------------------------------

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail


End of procmail Digest, Vol 94, Issue 21
****************************************



      

Attachment: mailfilter
Description: Binary data

____________________________________________________________
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>