I plucked this recipe from the FAQ's for rc.local.s20. It isn't working at all - no footers are getting inserted. Any clues what may be wrong?
Can you also explain how much of the footer.txt files this 'pulls in' to compare against the message?
Jo
# # Add text below each message - this one prevents duplication #
TEXT=`sed -n '2 p' <footer.txt` :0 fbBw * $ ! $\TEXT | cat - footer.txt
Jo wrote,
| I plucked this recipe from the FAQ's for rc.local.s20. It | isn't working at all - no footers are getting inserted.
Actually, it might be working too well and preventing the footer from being inserted.
| Can you also explain how much of the footer.txt files this | 'pulls in' to compare against the message?
Apparently it looks for the second line of the footer file, without anchors. If the second line of the footer is blank, no message will ever get a footer.
| TEXT=`sed -n '2 p' <footer.txt`
YECCH. Far better,
TEXT=`sed -e1d -eq footer.txt`
| :0 fbBw | * $ ! $\TEXT | | cat - footer.txt
At the least, make the condition
* $ ! ()<$\TEXT$
so that a hit prevents adding the footer only if it begins with the start of a word and ends at the end of the line.
Thank you for your assistance. I tried this then:
TEXT=`sed -e1d -eq footer.txt` :0 fbBw * $ ! ()<$\TEXT$ | cat - footer.txt
Works great, but also seems to need at least 2 lines in the footer. Is there a way to make it work for a one line footer?
I am SLOWLY learning how to write shell scripts and procmail recipes, but my knowledge of sed and cat is nil at this point!
Jo
Jo asked,
| Works great, but also seems to need at least 2 lines in the footer. Is there | a way to make it work for a one line footer?
To make it work for exactly a one-line footer, sure:
TEXT=`cat footer.txt`
but to make it look for the second line of a file with two or more lines but the only line in a one-line file would be nasty in sed. Pick your poison:
TEXT=`sed -e$q -e1d -eq footer.txt` or TEXT=`sed -e2q -e$q -ed footer.txt`
Another way to deal with a one-line footer is to add a blank line above it so that it now is a two-line footer (with a blank first line).
smartlist@lists.rwth-aachen.de