1999-05-13-15:51:14 Rajeev Yadav:
I need to send all emails from root to a pager program. I have the
following in my .procmailrc. How can I send From: Subject: and Body < 512
bytes to my other program?
Perhaps something like (untested):
:0 c
* ^From: .*root
| sed -ne/\^From:/p -e/\^Subject:/p -e'/^$/,$p'|\
dd bs=1 count=512 2>/dev/null|\
your-pager-program
Alternatively, if you preferred firing up one perl over a sed and a dd, you
could use
:0 c
* ^From: .*root
| perl -le '$/="";for(split /\n/,scalar(<>)){print if
/^(From|Subject):/};undef $/;print substr(<>,0,512)'
That does something slightly different; the 512 bytes is measured in the body,
only. Not sure which you meant.
But if I were doing this for my own use, I'd write an external helper program
(in perl) which would eat a whole message on stdin, rip out the bits of
interest, and feed them to the pager; hence the procmail would just be
:0 c
* ^From: .*root
| helper
and helper could take its time and do whatever processing, filtering, data
reduction, etc seemed desireable.
How does your pager respond to characters with the high-order bit set, just as
a for instance.
-Bennett