procmail
[Top] [All Lists]

Re: Executing programs

1997-05-11 09:13:00
just set this up as an alias or something ... then with your .forward
forward the mail to both places ... like in you /etc/aliases create a
line like this:

test :  "|/home/youraccount/tester"


then create tester as a shell script or whatever code you want to use
...  the mail will be sent there as standard out ...  you can then grep
for it ...
cat -E I think it is will print a $ at the end of each line if that
helps you at all with the program ...
I also tried to werite a similar program to take emails and add them to
the end of a web page ... so any emails sent like say to a majordomo
mailing list would get noted on a web page with that date on it so
people can look up what was said on the mailing list via www

does anyone know how to sub a <p> for a $  that is the part of the
script that I had problems with ....  please help.

like at the end of each line I addes a $ using cat -E  but now I want to
add a <p> there instead of the $ so I want to find all of the $ and get
rid ofthem and add a <p> there .  I tried to use tr but as far as I know
you can only sub 1 to 1 and not 3 chars for 1.   I thought of taking all
of the spaces and puting them to their own line then grepping for $ then
if it is found sub the $ for a < and echo a "p>" after it ...  but then
this is really a mess ... can anyone help???



era eriksson wrote:

On Sat, 10 May 1997 10:11:29 +0000, "Larry Canter"
<Larry(_dot_)Canter(_at_)gridsat(_dot_)thegrid(_dot_)net> wrote:

(You wouldn't happen to be married to someone named Martha? :-)

 > I need to save e-mail to a file(stripping out the headers), and then
 > call a program with the file-name as an argument.  Saving the mail to
 > a file is no problem, but I can't get the program to execute.  Recipe
 >  in .procmailrc looks like this:
 >       :0 bc
 >      | cat >>$HOME/filename
 >      | program_name filename
 >
 > I've tried it using semi-colon at end of the first action, placing
 > the program execution in a separate recipe, and the same thing
 > happens - the file is created and that's it.

The action line can only be a single line, but it can contain several
commands. (You can splice it onto several lines by using a backslash
escape on the newlines.) You will then probably have to figure out how
to lock the file $HOME/filename (and you should name a full pathname
in both places where you reference the file) if it makes a difference
to program_name what's in the file at a certain time.

    :0bc:$HOME/filename$LOCKEXT
    * conditions for when this should be done, if any
    | cat >>$HOME/filename \
    ; program_name $HOME/filename

(The FAQ I have at http://www.iki.fi/~era/procmail/mini-faq.html
attempts to describe this file locking business a little bit, you may
want to read that.)

Finally, here's an alternative solution. The h flag on the second
recipe is there on the assumption that the header will usually be
shorter than the body of the message. The only meaning of it is to
minimize what is written to program_name, since it will ignore its
input anyway:

    :0 c
    * conditions anyone?
    {
        :0bc:
        $HOME/filename

        :0hi
        | program_name $HOME/filename
    }

If the recipe really is unconditional, you can skip the braces.

    :0bc:
    $HOME/filename

    :0hic
    | program_name $HOME/filename

Perhaps you could code program_name or write a simple wrapper script
around it so it will accept the current message on standard input and
add it to the end of the data file itself. This will encapsulate the
action nicely and presumably make the thing more self-contained.
  (You also rid yourself of the aesthetic glitch of copying and piping
stuff into a program which ignores the data you pipe to it. Procmail
currently has no really idiomatic way of simply executing a program in
its own right, without feeding it the current message on standard
input. It's easily done with a | action with an i flag but this
construct sort of bothers me ... It would be nice with a new action
line directive for this purpose. Stephen, are you listening?)

Hope this helps,

/* era */

--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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