| Signature Rotator |
|---|
|
Since the old BBS I have missed the common capability of news readers to introduce a random signature at the end of each post. That feature is lacking in all the major news readers today. They only allow you to point to one signature file. So that signature file has to be changed. There are some large programs to do that. To me they have been so well documented that I have not figured out how to get them to work. I am not naming names and I admit I am new to linux. So I decided to create this feature myself. My first approach was a clean Pascal program implementing random file selection. It was huge and had several drawbacks. But then I realized if the sigs were changed rapidly enough, random was not required. Therefore a simple script could be used. My first approach required stopping, editing, and restarting the script every time I added a signature to change the upper limit to the number of the new signature. That was a drawback which I was able to correct. This is my first public release. It allows adding signatures on the fly while the program is running and the script will automatically include the new signature as long as it's filename is sequentially the next largest number. It also permits running programs which produce variable outputs such as the hodie example included. This should be simple enough for a linux newbie. I have only been into it for about nine months and that is pretty new. It only looks a little complicated as $i has to be used as both a variable for increment and compare, and as a filename. There are certainly simpler ways someone with serious script writing experience can do it. Simply save the script below, perhaps save the page as a file with the name rest and edit out everything not part of the script. Move it to a directory where you want it to run, say mkdir sigs cd sigsCreate your signature files there with filenames 1, 2, 3, 4 and so forth. Then type ./rest &The & makes the program run in the background freeing the terminal for other uses like adding signatures. Finally find the place in your news reader and email programs where you can define a signature file and direct it to the file ~/sigs/sigrotate presuming you are using the directory sigs in your home director. This can be run in different directories to have different signature files for news and mail. (Now will someone write a newsreader allowing different personalities and signatures for each newsgroup?) The cleanest way to delete a signature is to copy the largest numbered signature to the number to be deleted and then delete the largest numbered file. I have made an effort to put all of the documentation in the script as comments so you don't need to index this page to use it. With all the unnecessary lines removed the working script is only 16 lines.
|
#! /bin/bash # above, if bash is some place else change that line to where it is # Matt Giwer, jull43@tampabay.rr.com, September 2000, GNU copyright # rest 1.0, Rotating Exceptionally Smart Things # first release # all comments may be eliminated # PURPOSE # this is to produce a rotating signature # each signature is sequentially copied into a single file named sigrotate # and that file is used as the rotating signature # RATIONAL # realizing that sigs need not be randomized as the time # to create a message causes them to be random enough for # government work when processed sequentially. # 60 files per minute with sleep 1 # if not random enough for you take out the sleep 1 # TODO # come up with something really clever REST can stand for # REQUIRES bash # this script and all signatures must be in the same directory as it is # written # initialize i to 1 i=`expr 1` # each sig is a file given the name of a number # 1 2 3 and so forth. Numbers much be sequential # 1 3 4 will not work # (if you have a large number of existing sigs # or find a sig collection look for a mass rename utility) # Hint: for correcting spelling and such include the number of the sig # that is the name of the sig in the sig # example: file name 20 contains # I love the smell of vaporware in the morning. 20 # (see comment in the second if section) # this permits running the program and adding or changing # sigs on the fly without stopping and restarting # and possibly modifying something for the new number of files # remember the courtesy limit of a signature is 4 lines # correctly no more than 320 (4*80) characters but that # can start a very boring and heated discussion # and some mail and news readers insist upon annoying you # with a four line reminder # invoke as ./rest & # point news and mail readers to the file sigrotate in the # directory where this runs as the signature file to use. # all sigs much be in the same directory where rest runs # unless you change the script to point to another directory. # set upper limit to more than the number of sigs you have # if you have more than 999 make this larger upperlimit=`expr 999` # dummy while loop, a loop that will run forever while [ $i -lt $upperlimit ] do # if a file exists copy it to sigrotate and increment i if ( test -e $i ) then cp $i sigrotate # echo $i >> sigrotate # see comment in next if section i=$(($i + 1)) # echo $i # is useful for testing only # sleep is unnecessary for hackers and this script sleep 1 fi # if it has run out of files do the special routine # and reset i to 1 # test for file to exist and if it does not ! if !( test -e $i ) then ######### # hodie is just a program to write in the current date # in Roman Empire style # insert any other program or eliminate the first # two lines and just reset i to 1 hodie -v > sigrotate echo ' -- The Ferric Webmaster' >> sigrotate # my normal sigs have -- The Iron Webmaster as a last line # it comes from The Iron Chef TV show # note that if you mass renamed and don't want to retype them # to include the file name you can # echo $i >> sigrotate # to identify it for change, correction or deletion # but do it in the first if after cp $i sigrotate not this if # to delete a file easily, cp the larger number file to the number # to delete then delete the largest number file ######### # reset i to 1 i=`expr 1` fi # end of dummy while loop but should never be reached # increase upperlimit if you do done # end script
Page reads: 6819