• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

procmail counter


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?
  • 4
  • 3
1 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
bryanlloydharrisAuthor Commented:
How do I make sure a bash script will return zero code?
the script exits with exitcode of last command.
If You want to override, call: exit 0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

bryanlloydharrisAuthor Commented:
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.
> 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?
bryanlloydharrisAuthor Commented:
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
bryanlloydharrisAuthor Commented:
I got it from the man pages.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now