Hello Jason!
On Sat, 10 Jun 2000, Jason Helfman wrote:
> On Sat, Jun 10, 2000 at 07:36:50AM +0200, Wilhelm Wienemann muttered:
> This is wonderful, but I am a bit of a newbie when it comes to
> scripting and whatnot. Is the first part of this a patch?
No, it's a macro-file. On my box I've all my macros in the
$HOME/.slrn directory and here it is called .slrn-mua.sl
To load (interpret) it with my $HOME/.slrnrc file I have to
add a line like
interpret ".slrn/.slrn-mua.sl"
-----------------------> cut here <------------------------ -
%
% replacement forward and reply functions for slrn.
% these will drop you to your normal mail user agent.
%
variable mua_script="/usr/local/bin/slrn-mua.sh";
define my_reply_to_article ()
{
pipe_article (Sprintf ("%s -reply", mua_script, 1));
}
define my_forward_article ()
{
pipe_article (Sprintf ("%s -forward", mua_script, 1));
}
definekey ("my_reply_to_article", "r", "article");
definekey ("my_forward_article", "F", "article");
---------------------------------------------------------
> How would I go about exectuing all of this...?
The following shell script wrapper is located as slrn-mua.sh
in the directory /usr/local/bin/
-----------------------------------------------------------
#!/bin/sh --
#
# A small script which is used to reply to or forward an
# article from within slrn.
#
# The article is expected to come on stdin, while $1 is either
# -reply or -forward.
#
# where is mutt located?
MUTT=/usr/bin/mutt
# where is formail?
FORMAIL=/usr/bin/formail
TMPDIR=${TMPDIR-/tmp}/`basename $0`.$$
mkdir -m 0700 $TMPDIR || { echo "can't create $TMPDIR!" >& 2 ; exit ; }
trap "rm -rf $TMPDIR; trap '' 0; exit" 0 1 2 3 4
cat > $TMPDIR/article
# get various headers
SUBJECT="`formail -z -x Subject: < $TMPDIR/article`"
DATE="`formail -z -x Date: < $TMPDIR/article`"
FROM="`formail -z -x From: < $TMPDIR/article`"
REPLY_TO="`formail -z -x Reply-To: < $TMPDIR/article`"
MESSAGE_ID="`formail -z -x Message-ID: < $TMPDIR/article`"
REFERENCES="`formail -z -x References: < $TMPDIR/article`"
exec > $TMPDIR/template
#
# functions
#
prepare_reply () {
if [ -n "$REPLY_TO" ] ; then
echo "To: $REPLY_TO"
else
echo "To: $FROM"
fi
if [ -n "$MESSAGE_ID" ] ; then
echo "In-Reply-To: $MESSAGE_ID"
echo "References: $REFERENCES $MESSAGE_ID"
fi
echo -n "Subject: "
if [ -z "$SUBJECT" ] ; then
echo "Re: your mail"
else
echo -n "Re: "
echo "$SUBJECT" | sed -e 's/^Re: *//'
fi
echo
echo "On $DATE, $FROM wrote:" | fmt
sed -e 's/^/> /' $TMPDIR/article
}
prepare_forward () {
echo "Subject: Fwd: $SUBJECT"
echo
echo "----- Forwarded message -----"
cat $TMPDIR/article
echo
echo "---- End forwarded message-----"
}
#
# main
#
case "$1" in
-reply)
prepare_reply
;;
-forward)
prepare_forward
;;
*)
echo "usage: `basename $0` {-reply|-forward}" >& 2
exit 1
;;
esac
exec > /dev/tty
$MUTT -H $TMPDIR/template < /dev/tty
-----------------------> cut here <------------------------ -
Note: The Shell-script needs the executable permissions for
its users. This is usually done by a 'chmod -v 755 slrn-mua.sh'
as root in the destination directory.
Now every time you use a 'r' to do a reply or a 'F' to do a
forwarding in slrn it will use 'mutt'.
Enjoy it! :-))
bye - Wilhelm
--
-- _ _ __ __ Wilhelm Wienemann <[EMAIL PROTECTED]>
| (_)_ __ _ _\ \/ / -> For a better taste - Linux Inside
| | | '_ \| | | |\ / -> Blue screens for Linux background only
| | | | | | |_| |/ \ -> Enjoy Linux and the Power of Open Source
|_|_|_| |_|\__,_/_/\_\ Registered-Linux-User: 70712 http://counter.li.org/