Fritz Feuerbacher asked,
| Hi, I would like to do the following:
| when an email comes in, I would grep it with the
| regex below. If it finds the line(s) it will set
| JUNK >= 1 if not JUNK = 0.
|
| This may sound stupid, but how can I use JUNK in
| a recipe to send emails to dev/null or a file.
| I know how to send the email to a file but how
| do I check the variable JUNK for either 0 or >= 1 ?
|
| JUNK=`grep -ci "Pro Bulk E"`
|
|
| :0
| * JUNK ?? (.|$) # this checks to see if its null?
| /dev/null
I think you're going about it the hard way, Fritz. You want to dump mail
into /dev/null if "Pro Bulk E" (case-insensitive) occurs anywhere in the
message, so that's something procmail is designed to do very well without
your needing to fork grep:
:0HBh
* Pro Bulk E
/dev/null
Also, in the approach you had in mind, $JUNK would never be null unless
grep failed to run: if the string wasn't present, $JUNK would be 0. If
you want to run a recipe only if a numeric variable is positive and not
if it is zero or negative, that can be done:
:0 flags
* $ $variable^0
action
but it is not the best way to do what you're illustrating here.