-----BEGIN PGP SIGNED MESSAGE-----
Hi David Reynolds! I'm a UNIX administrator, spamfighter, and a virusfighter!
P.S. Feel free to make fun of the script, change it around or
otherwise humiliate me :)
YES!! I get to have some fun! :-)
I use the following script to re-write incoming email messages, I
want to limit the message body to the first 20 lines. My question
is, within the following script how would I , or could I do that?
I'll comment on your script first, then have a "cleaned up" copy
at the bottom.
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
Probally not needed, as procmail sets its own path.
export PATH
Ditto.
formail -k -X From: -X Subject: >> /tmp/david.test.$$
mail -s "David Reynolds" david(_at_)stuffage(_dot_)com </tmp/david.pager.$$
rm /tmp/david.test.$$
Huh?
My original thought was to use something like this:
head -20 /tmp/david.test.$$
but it didnt work either, it piped the output to the screen, not to
the file.
Ok, let's try something like this: (I'm trusting that your
formail syntax is correct)
#!/bin/sh
TEST=/tmp/david.test.$$
MAIL=/tmp/david.mail.$$
# Defining temp files like this is always a good idea so that your code
# becomes much clearer.
formail -k -X From: -X Subject: >$TEST
# ok, now we need to seperate the header and the body
# first, we get the header
sed -n /"^From"/,/"^$"/p <$TEST >$MAIL
# and now the body, we start the second copy of sed at line 2
# because the first line is the blank space that seperates the header from
# the body, and we already have it in $MAIL from the last sed command
sed -n /"^$"/,/"\000"/p <$TEST |sed -n 2,21p >>$MAIL
mail -s "David Reynolds" david(_at_)stuffage(_dot_)com <$MAIL
# cleanup
rm -f $TEST $MAIL
# End
If you're not TOO dizzy after reading that, type it in and lemme
know how it works. :-)
Regards,
<Doug Muth> ----- <http://www.ot.com/~dmuth> ---- Est sularus oth Mithas!
Co-author of the SPAM-L FAQ -=-=-= http://www.snowpoint.com/spam-lfaq.txt
Anti-virus software and utils -=-=-=-=-=-= http://www.ot.com/~dmuth/virus
Because the only GOOD spammer is a DEAD spammer! || http://spam.abuse.net
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Send a blank e-mail to dmuth+help(_at_)ot(_dot_)com for my public key
iQCVAwUBM0m8gR0LJlIsPN1JAQHsuwP/W3D94sMwBA/+BseyvvQi2O722/vrgWr/
U5wa855upMEVVq1QMoq9VwYIIN0cPt9vlQs+u9co7hKcHjboNIEGalpY9Ftm2Z/B
Zv2mbt2FtpgBIBFf1WMilFrSX6IdgjvtYc9S4/xy3Ts2dUnPxen8X6kc1aNkiGVV
otyqwfsWpC4=
=6uCZ
-----END PGP SIGNATURE-----