procmail
[Top] [All Lists]

Re: CC, notify and logging

2001-09-03 16:36:43
Tim Holmes <tim(_at_)unixtechs(_dot_)org> writes:
...
Should I create a script instead, to then send the message to the text
pager?  Or should I edit this to read something else?  Here's the
receipe I'm trying to use.

:0
* ^From:(_dot_)*$USER(_at_)`hostname`
{
        LOGABSTRACT=all
      :0 hwic
      | /bin/cat $HOME/test-file | /bin/mail $USER(_at_)page(_dot_)`hostname`

      :0
      misc
}

Don't use full paths for programs: that's what PATH is for.  Next, the
HOST variable contains the hostname of system that procmail is running
on, so there's no need to run the hostname command to get it.

Speaking of which, procmail doesn't to variable or command (backquote)
expansion in conditions unless you put a '$' before the regexp itself,
that's why procmail wan't expanding the $USER or `hostname` in the
condition.

Oh, and procmail doesn't set the USER variable by default.  It sets the
(POSIX-compliant) LOGNAME variable instead.

Also, we can eliminate the use of the 'cat' command by using a redirection
instead, thus saving a pipe, a fork, and an exec.

So, fixing those, we get:

        :0
        * $ ^From:(_dot_)*$LOGNAME(_at_)$HOST
        {
                LOGABSTRACT=all
                :0 wic
                | mail $LOGNAME(_at_)page(_dot_)$HOST < $HOME/test-file

                :0
                misc
        }
                



Subba Rao <subba9(_at_)home(_dot_)com> writes:
...
In your original receipe, you had 2 ORs (|)

     | /bin/cat $HOME/test-file | /bin/mail $USER(_at_)page(_dot_)`hostname`

I can't give a good explanation of the 2 ORs on the same command line. It is
not interpreted as a pipe in procmail.

Huh?  If it's in a '|' action, then it certainly is a pipe, as procmail
will hand off the command to $SHELL which will then treat it as a pipe.


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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