Dynamic Signatures

Julian M Catchen plug-discuss@lists.PLUG.phoenix.az.us
Wed, 9 May 2001 23:11:53 -0700


FIFO was the keyword.  After you said that I took a quick look at the camel
book and found that they had a section on named FIFOs and their example was
using one as an email signature.  So, all you have to do is this:
1) Turn your .signature file into a fifo using the mkfifo command
2) create a Perl program (any program will do -- python, c, whatever) that
will open up .signature as a pipe and write its output there.

Here is some example code that writes my sig with the current date (one of
many possibilities):
---------------------------------------------------------
#!/usr/bin/perl

use POSIX qw(strftime);
use strict;

chdir;  # go home
my $FIFO = ".signature";

while (1) {
  open FIFO, ">$FIFO" or die "Unable to open $FIFO\n";
  my $date = strftime("%a %b %d, %Y %I:%M:%S%p",localtime);

  print FIFO "j. m. c a t c h e n | (t o p e k a)\n",
             "          p  h  x ,  a  z          \n",
             "j u l i a n @ c a t c h e n . o r g\n",
             "c a t c h e n . o r g / t o p e k a\n",
             "     $date\n";
  close FIFO;
  sleep 1;
}
--------------------------------------------------------------

This works with cat, more, etc.  Unfortunatley, I did find out that some
mail programs do a stat on the sig file prior to opening it to find out how
big it is.  If they do that to a pipe, it will return a value of zero and
your pipe will be broken.  So, it doesn't seem to work for everything.

Thanks everyone for the help!

julian



On Wed, 09 May 2001 21:15:28 Nick Estes wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Most programs that read a signature file can also call a program instead
> (I do it in pine all the time, mutt can do it too).  Alternatly, instead
> of having a normal file for you .signature, you could try making it a
> named fifo, then just write a program to stuff it with your signature
> data
> everytime it's read from.  (the first option is by far the easiest if
> your
> client supports it)
> 
> 	--Nick
> 
> On Wed, 9 May 2001, Julian M Catchen wrote:
> 
> > Ok, I have a question that will either be answered really easily, or
> not
> > answered at all:
> > 
> > Is there a way to have your email signature file generated dynamically?
> 
> > What I mean by that is not simply a program that regenerates it every
> so
> > many minutes as a cron job, but a mechanism that would regenerate it
> > whenever the file is opened for reading.  So, kind of like the /proc
> > filesystem where files appear to be real, they can be read or written
> to,
> > but in reality they are functions that are executing whenever the proc
> file
> > is opened for reading or writing.  
> > 
> > If this is possible, then all standard mail programs could use this
> dynamic
> > file without changes.
> > 
> > So, any takers (or am I totally off with this)?
> > 
> > Thanks,
> > 
> > julian
> > 
> >