NAME

randsig - Output random signatures through a named pipe.


SYNOPSIS

randsig [ -f, --fifo=filename ] [ -r, --realsig=filename ] [ -s, --sigsave=filename ] [ -c, --command=command ] [ -q, --quotes=filename ] [ -n, --nfs, --nonfs ] [ -o, -1, --once ]

randsig -k, --kill

randsig -v, --version

randsig -h, --help

randsig -H, --man


DESCRIPTION

Randsig attempts to create a FIFO (First In First Out, or a named pipe.) to control what is seen by programs that try to read your signature. As its name suggests, it outputs random text plus any other constant text you specify.


OPTION FORMAT

Each long option has an equivalent short option. For the long options, case doesn't matter and they may be abbreviated to uniqueness. The options all override the corresponding config file parameters (see CONFIGURATION FILE OPTIONS).

The --nonfs option is a special case. It only has meaning if you have defined NFS in the configuration file and want to turn it off temporarily.

Using the --quotes (-q) option resets any previously defined COMMAND option, either in the configuration file, or on the command line.

The --kill and -k options attempt to kill a running randsig process. The only other options that have any meaning with this option are the --nfs, -n, and --nonfs.

Note that this isn't safe to use if you're running over an NFS filesystem.

The --once, -o, and -1 option will print one random signature on the standard output and exit. This can be used even if there's a randsig running in the background.

The --version and -v options print out version and copyright information, then exit.

The --help and -h options print out a short option summary and exit. All other options are ignored.

The --man and -H options bring up this man page and exit. All other options are ignored.


INTRODUCTION

First some stuff about a document called ``so1036'' (Son Of RFC1036):

Delimiter

The document explains that a signature file should always start with a line that contains the three characters dash, dash, space (-- ) alone on the line. Some news and email software even use this delimiter to locate the signature.

Therefore, this script will put it there at the top if it does not appear exactly like that somewhere in the signature.

If you get a second line with the two dashes on it when you read in your signature, check to make sure that the signature file that this script uses either has it as '-- ' or doesn't have it at all.

This delimiter line does not count towards the number of lines in your signature.

Signature Size

The document also says that signatures shouldn't exceed four lines, which makes it difficult to run this thing and comply. It's possible though. I suggest that as a general rule, ascii art, lines that are used as seperators (such as a line of stars, dashes, equal signs, etc..), blank lines, and so on should be removed.

At one time, my signature contained two lines of constant text. In these two lines, I had my full name, my email address, my ICQ number, my web page URL, and a sentence that details how to obtain my PGP public key. This leaves two lines for random quotes.

In my opinion, signatures that exceed eight lines are unacceptable! So this script will complain if your signature is more than seven lines. (Remember that a random quote will usually add at least one line to the signature.) If someone needs more information than will fit in that space, email it to them in a seperate, personal message instead of making everybody you write suffer through an overly large signature.

Thank you for your cooperation in making the 'net a better place.


SHUTTING DOWN

Once the program is running, it creates a file in your home directory with the name .programname-pid (usually .randsig-pid) with the process ID number of the program in it as the only line.

This makes it easy to shut the program down by doing something like: kill `cat ~/.randsig-pid`

Or better yet, just use the -k option. (See above.)


CONFIGURATION FILE OPTIONS

This script looks for a configuration file on startup that tells it how to run, and what files to use at runtime.

The file name is .programname-config (usually .randsig-config), and consists of NAME=VALUE pairs. Blank lines and lines that start with # are ignored.

Note that this file is parsed before the command-line options, so command-line options override anything set in this file. (See OPTION FORMAT above.)

The configuration parameters are:

Example:

 FIFO    = .signature
 REALSIG = .signature-text
 SIGSAVE = .signature-save
 #COMMAND = fortune -s
 QUOTES  = .signature-quotes

Since the COMMAND line starts with a #, it is ignored (also known as a comment), and the QUOTES paramater is used.

The default location for all of these files is your home directory. You may specify full pathnames if you wish, however.

Caveat:

The configuration paramaters that take filenames as their value should not have the same value. Doing so could have unpredictable and undesirable results. This script does not, and will never check for this occurance. If you do it, the assumption is that you know what you're doing.


QUOTE FILE FORMAT

A quote file, if you use the internal mechanism, is in the following format:

 quote one
 rest of quote one
 %
 quote two
 %
 quote three
 more of quote three
 rest of quote three
 %
 etc...

Basically, you just seperate your quotes with a % on a line by itself.

If you want one of your quotes to have a line with a % at the beginning by itself, add some white space after it. (Such as a space.)


SIGNATURE FILE FORMAT

The signature file will have the quote placed at the end of the file, or it will be inserted in the place of the first __ADDQUOTE__ it sees. Any subsequent lines that contain an __ADDQUOTE__ will be printed as normal.

In addition, you can have the quote padded with spaces on the left side, right side, or both (centering).

This is accomplished by using one of the three: __ADDQUOTE<somenumber>__ This adds spaces on the right. __ADDQUOTE+<somenumber>__ This adds spaces on the right. __ADDQUOTE-<somenumber>__ This adds spaces on the left. __ADDQUOTE.<somenumber>__ This centers.

All of these options pad each line of the quote until it's <somenumber> in length. If the line is already longer than <somenumber>, the line will not be truncated, or even padded.

This makes it easy to have quotes that are only a few words inserted in the middle of a line between some other text, a box, or in some ascii art.

If you want to use this feature make sure all your quotes are one line, the command you're using will never output more than one line, or your signature won't look odd with multi-line padded quotes. (See the last example below to see how this is currently handled.)

Whitespace is allowed between the word ADDQUOTE and the number, it is simply ignored.

Eg: __ADDQUOTE .56__ __ADDQUOTE 40__ __ADDQUOTE -50__

This is so you can preserve formatting in your signature if you're embedding a quote in the middle of a boxed line, or something.


EXAMPLES

If the script were set to run the command: date ``+%I:%M %p %b %d %Y''

And the .signature-text file contained: -- Sent at: __ADDQUOTE__ John Doe <jd@abc.net>

It would show up as: -- Sent at: 11:20 AM Dec 08 1997 John Doe <jd@abc.net>

Padding Examples

If your .signature-text file containined something like: -- Random quote: __ADDQUOTE 20__ John Doe <jd@abc.net>

It would show up something like: -- Random quote: (Random quote) John Doe <jd@abc.net>

Or if you used __ADDQUOTE-20__ instead: -- Random quote: (Random quote) John Doe <jd@abc.net>

Or if you used __ADDQUOTE.20__ instead: -- Random quote: (Random quote) John Doe <jd@abc.net>

Default

If your .signature-text and your .randsig-config file was blank, the output might look like: -- Arithmetic is being able to count up to twenty without taking off your shoes. -- Mickey Mouse

Lastly, if you had decided to use some kind ascii art or border, but your quotes were multi-line, eg: -- -------------------------------------------------- >_ADDQUOTE .48__< --------------------------------------------------

You'd see something like: -- -------------------------------------------------- > Some < > multi-line < > quote. < --------------------------------------------------

It just prepends and appends the same text that occurred respectively before and after the __ADDQUOTE__ to each line.


FILES

Unless specified differently in the config:

~/.signature

Your signature file.

~/.signature-text

File that contains the text to use at runtime.

~/.signature-save

File to save your 'original' signature in.

~/.signature-quotes

File to get quotes from, if you're not going command based.

~/.randsig-config

Program config file.

~/.randsig-pid

Program PID file. (Also acts as a lock file.)

These last two filenames are actually determined by the executable name. The word ``randsig'' will be replaced by whatever the executable is named.


NOTES


CAVEATS

This program traps most signals and tries to restore your original signature when it exits, but if for some reason this doesn't happen, your signature file will remain a named pipe (FIFO), and anything that tries to read from it might hang. Usually you can just start this program and the reading process will come back. You might have to remove your ~/.randsig-pid file first, though.

If that doesn't work, kill the reading process, make sure this program isn't running, remove the FIFO, and then start this program back up.

Caveat Emptor

This program comes WITHOUT ANY WARRANTY! Express or implied. In other words, USE THIS AT YOUR OWN RISK! I am not responsible for ANY lost data as a result of running this program.


DIAGNOSTICS

I hope the error messages are clear enough. You should have no problems if you actually bothered to read this documentation.

If all else fails, read the code, or complain to me.


BUGS

Probably, the code is an absolute mess. If you find a bug, want to see something added or changed, have a comment on my documentation, or just want to praise me, feel free to email.

The script can die silently once it's gone into daemon mode. There are warn/die statements that would normally print diagnostic information, but the STDERR filehandle points to /dev/null. I may create a way to specify a log file in the future.


AUTHOR

Christian J. Robinson <heptite@gmail.com>


COPYRIGHT

Copyright (C) July 1997, June 1999, August 2010 Christian J. Robinson.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Comments, questions or bug reports can be sent to heptite@gmail.com Make sure to say that your message is regarding the randsig program.


SEE ALSO

mkfifo(1), mknod(1), perlipc(1), fortune(6), so1036