Sig Block Fortune Cookies

These were popular back in the olden days of FidoNet.  I’d like to start reviving them:  Fortune cookies in sig blocks.  I wrote a perl script this afternoon to insert a fortune cookie into a .signature file.  Here’s the code:

#!/usr/bin/perl
use warnings;
use strict;

# sigmaker - makes signature blocks using a templace and the fortune program
my $HOME           = $ENV{'HOME'};
my $FORTUNE        = "/usr/games/fortune";
my $TEMPLATE       = "$HOME/.signature_template";
my $FORTUNE_STRING = "_fortune_";

open (FTEMPLATE, $TEMPLATE) or die $!;
open (SIG, ">$HOME/.signature")  or die $!;

my $fortune_text = `$FORTUNE`;
my $line;

while ($line = <FTEMPLATE>) {
        $line =~ s/$FORTUNE_STRING/$fortune_text/;
        print SIG $line;
}

close SIG;
close FTEMPLATE;

I have it set to run hourly out of my crontab. Here’s my template file:


Joshua M. Armstrong
jarmstrong@wi.rr.com
_fortune_

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT/CS d- s+:+ a- C++ UL+++ US++ UV+ UB P+ L++ E--- W++ N+ o? K? w O M V-
PS+ PE@- Y- PGP+ t- !5 !X R+ tv b+ DI++ D+ G e++>+++ h! r--- !y UF++(+)
------END GEEK CODE BLOCK------

All it does is replace the _fortune_ string with the output of the /usr/games/fortune program:


Joshua M. Armstrong
jarmstrong@wi.rr.com
Q:      What's the difference between USL and the Titanic?
A:      The Titanic had a band.


-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT/CS d- s+:+ a- C++ UL+++ US++ UV+ UB P+ L++ E--- W++ N+ o? K? w O M V-
PS+ PE@- Y- PGP+ t- !5 !X R+ tv b+ DI++ D+ G e++>+++ h! r--- !y UF++(+)
------END GEEK CODE BLOCK------

The mailer takes care of the –\n sig delimiter line.

Advertisements

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: