* Sven Burgener <[EMAIL PROTECTED]> wrote:

> Is there a way to put some sort of random signature system to
> use in mutt?

Untested:

#!/usr/bin/perl
# Version: let's call it 0.9.9, date: Tue, 25 Apr 2000 21:03:36 +0200
# Version: 0.9.9a, date: Sun, 30 Apr 2000 17:54:44 +0200
# Written by Eduard Bloch, Licence: GPL Installation is simple: copy
# this somewhere, in your home directory for example, make it executable
# (chmod +x) and start it. You may want it be started at boot time, just
# put a command like this in a init-script:
# su -c '/usr/bin/sigrot' user

# WARNING: First created the .signature fifo, don't forget to run
# sigrotate before using the client program. Otherwise you will wonder
# what the program is waiting for.

$signaturedb=$ENV{"HOME"}."/sigs";
# file where the signatures are stored in
# The format is simple: many signatures separated by lines containing "-- "
# or "--<Return>"

$signatur=$ENV{"HOME"}."/.signature";
# file to be used by news/mail agents as the signature source. If
# exists, the file will be renamed and a fifo will be created in its place

$psfile=($ENV{"HOME"}."/.psig");
# specify a file for personal stuff like "/me is Foo Bar <[EMAIL PROTECTED]>"

$lockfile=($ENV{"HOME"}."/.sigrot.lck");
# specify a file for personal stuff like "/me is Foo Bar <[EMAIL PROTECTED]>"

$parm = $ARGV[0];
if($parm =~/^-help/)
{
#print "Usage: sigrotate [-ps|-sp leftwidth separator rightwidth]\n"; 
exit 0;
};

if(-f $signatur)
{rename($signatur,$signatur.".sr".(time)) || die "Old signature found and 
couldn't be renamed\n" }

if(!-p $signatur){system "mkfifo $signatur" || die "couldn't create fifo file"};

sub spalten {
($text) = @_;
$text =~ s/\n|\r/ /gi;
return $text;
};
open(LOCK,">$lockfile");
if(flock(LOCK,2|4)){
# Wenn nicht gelockt, dann locken
        flock(LOCK,2);
        print STDERR "Starting sigrotate using $signaturedb, forking to 
background." if($ARGV[0] ne "-q");
}else{
        print STDERR "Signature Rotator is already running...(exiting)\n" 
if($ARGV[0] ne "-q");
        exit 1;
};

if(!($a=fork))
{while(1){
        $i = 0;
        undef(@sigs);
#       chdir($ENV{"HOME"}."/testing");
        open(fifo,">$signatur");
#       fifo geöffnet, warten bis ein Programm liest
        open(sigfile,"<$signaturedb");
        while(<sigfile>)
                {
                $sigs[$i].=$_ if(!/^--(\n| )/);
                $i++ if(/^--(\n| )/); 
                };
        close(sigfile);

        # uncomment the following line to add "-- " if the client program 
doesn't do
        # this automaticaly - not needed by the the most user agents
        # print fifo "-- \n";

        # now, use this construction below to import the personal stuff from a
        # file (~/.psig)
        open(person,"<$psfile");
        while(<person>){print fifo $_};
        close(person);

        $sigraw=$sigs[sprintf("%.0f",(rand($i)))];

# WIRD SPAETER IMPLEMENTIERT
#       if($parm =~/^-/)
#       {
#               print fifo "test".spalten($sigraw);
#               # in entw.: Spalten mit Trennzeichen, Breite fest über Parameter
#               # oder variabel (so breit das der text die gleiche Länge hat)
#       }
#       else
#       {
                print fifo $sigraw;
#       };

  close fifo;
        sleep 1;
}
}
print "..done.\n"  if($ARGV[0] ne "-q");

Reply via email to