Bennett,
Thanks for your feedback. I see your point and tried
your recipies. I guess, it needs a bit tweaking. Meantime, I tried the
following and it seems to be working.
:0
* ^From[ :].*root
| formail -k -X From: -X Subject: | head -n 15 | pagerprogram
Ahh the plain old head and tail stuff. Arent they handy at time? :)
I agree with your point that it would be much neater to use another
helper program (perl) to do it all and then pipe. I guess,
formail seems to be working fine for time being. I wonder if anyone
can think of any major drawback here!
Regards,
-Raj Yadav
On Thu, 13 May 1999, Bennett Todd wrote:
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