procmail counter

Posted on 2006-05-23
Last Modified: 2008-03-10

Is there a way to count the number of times a procmail recipe gets run?

I run this from bash:
expr $(cat /home/bryantest/count) + 1 > /home/bryantest/count

Does anyone know how to put it in a procmail recipe?
Question by:bryanlloydharris
    LVL 43

    Accepted Solution

    I have never tested, if procmail evaluates conditions in lazy way. Pleas test.
    But if so, then

    * your first condition
    * your second
    * ? /path/to/bumper.script.which.must.return.zerocode
    LVL 3

    Author Comment

    How do I make sure a bash script will return zero code?
    LVL 43

    Expert Comment

    the script exits with exitcode of last command.
    If You want to override, call: exit 0
    LVL 3

    Author Comment

    Well it is counting but it is not performing the action.

    What if I copy/paste the script here?  Do you think you could get it to work?  I will raise points if necessary.
    LVL 43

    Expert Comment

    > Well it is counting but it is not performing the action.
    then procmail is not lazy - I assume - and fires this check even some previous failed.
    Maybe the recipe/action itself is a script?
    LVL 3

    Author Comment

    I'm not sure maybe it is.  Here it is.  Notice I added the extra to line 10.

    SHELL=/bin/sh    # for other shells, this might need adjustment

    :0 Whc: vacation.lock
    # Perform a quick check to see if the mail was addressed to us
    * $^To:.*\<$\LOGNAME\>
    # Don't reply to daemons and mailinglists
    # Mail loops are evil
    * !^X-Loop: your@own.mail.address
    * ? /home/bryantest/procmailcounter
    | formail -rD 8192 vacation.cache

    :0 ehc         # if the name was not in the cache
    | (formail -rI"Precedence: junk" \
    -A"X-Loop: your@own.mail.address" ; \
    echo "I received your mail,"; \
    echo "but I won't be back until Monday."; \
    echo "-- "; cat $HOME/.signature \
    ) | $SENDMAIL -oi -t
    LVL 3

    Author Comment

    I got it from the man pages.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now