Subject: Random Signatures in Pine

From: [email-masked] (Andrew Philip Fabbro)
Date: 12 Jan 1996 21:48:37 GMT

====================================
Random Signatures in Pine (for Unix)
====================================

-----------
Quick Intro
-----------

Pine has a nifty little kludge that allows it to call an external editor
(CTRL-_ -- control-underscore).  In actuality, it can call any external
program, which allows you to do Many Cool Things.  Examples: a script that
strip headers for forwarding mail, a script that strips off excess >'s, or
a script that does random signatures.  Of course, if you want all three,
you can have a script that gives you a menu allowing you to choose which
function you want.  (Note that Pine also has another kludge, the |
command, which allows you to pipe messages into any external program --
exploring those possibilities is left as an exercise for the reader). 

So...you want random signatures.  Easy enough.  Enclosed is a script that
does it.  

------------
Requirements
------------

Obviously, if you're using the CTRL-_ command to actually use an alternate
editor, you can't use it to append random sigs.  (But then, most alternate
editors allow you to call external programs from within them anyway). 

It's a perl script, so if your system doesn't have perl, it won't work. 
To find out if you have perl, type "perl -v" without the quotes at the
Unix prompt.  If you get back a message that says "This is perl," you have
perl.  If you don't, you don't. 

------------
Installation
------------

1. Make a directory in your home directory where you will store your
signatures:

           cd
           mkdir signatures

"signatures" is the default.  If you use something else, edit the second
line of the script (that line that starts with $SIGS_DIR=) to whatever
name you're calling your directory.  For example, if you were calling your
signatures directory "siggies", then that line of the script would read

           $SIGS_DIR="$ENV{HOME}/siggies"; 

2. Edit this file, removing everything up to (but not including) the
#!/usr/bin/perl line (#!/usr/bin/perl should be the first line in the
file).  Save the edited file in your home directory and call it "randsig". 

3. While at the Unix prompt, give this command:

           chmod 700 randsig

4. Now fire up Pine.  At the main menu, type S (for Setup) and then C 
(for Config).  You'll see the Pine config menu.  Look for these two lines:

            [X]  enable-alternate-editor-cmd
            [ ]  enable-alternate-editor-implicitly

If you don't have Xs in the right place, use the arrow keys to move to the
boxes you need to change and then press ENTER to toggle the X. 

5. Almost done.  Now tap the space bar two or three times until you reach 
nearly the end of the configuration file.  The line you're looking for is 

            editor                 = 

Move the highligt bar over that line and press C (for ChangeVal).  The
enter "randsig" without the quotes and press return.  Now press E to exit
config. 

You're done!

--------
Using It
--------

Store each signature you want to use as a separate file in ~/signatures
(or whatever you called it).  Whatever files you store in ~/signatures are
candidates for the random signature script, so only store signatures in
that directory.  You can have as many as you want.  The file names are
inconsequential. 

To use the script, simply compose or reply as normal, then press CTRL-_
(control-underscore) when you're done.  Pine will call the script which
will append a signature and put you back into the Pico editor.  Then (as
usual) press Control-X to send your message. 

----------
The Script
----------

#!/usr/bin/perl

# Edit this line to the directory where you keep your sigs
$SIGS_DIR="$ENV{HOME}/signatures";

opendir (DIR,$SIGS_DIR) || die "Can't open directory $SIGS_DIR!";
@signatures=readdir(DIR);
closedir(DIR);
shift(@signatures);

$num_sigs = @signatures;
srand (time|$$); # seed with the least significant part of time
$chosen_sig_number=int(rand($num_sigs))+1;
$chosen_sig_name="$SIGS_DIR/@signatures[$chosen_sig_number]";

# I know, I know -- this next command is UGLY.  I'm sure there's
# a Perl Way<tm> of concatenating files, but I didn't feel like digging 
# through the Camel book to find it.
system ("cat $chosen_sig_name >> $ARGV[0]");