home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh
- #
- # csh script program "catsig", Copyright 1990 by Kent Paul Dolan, 94039-0755.
- #
- # The purpose of catsig is to add to the end of a letter or news article
- # (from the editor) a signature block consisting of the contents of
- # home directory file ".siggie", and the contents of a "random" member of
- # a list of home directory files with names of the form ".sig[0-9]*". The
- # .sig[0-9]* file names do not have to be sequentially numbered.
- #
- # Uses: from within mail, say "~r !catsig"; from within vi, say
- # ":r !catsig". Executables "catsig" and "timemod" must be in your
- # executable file path list.
- #
- # catsig uses two auxiliary files in the home directory, .sigtemp and
- # .sigpick, sets a csh environmental variable SIGPICK, and requires
- # at least the old version of "awk", and program "timemod"by the current
- # author, distributed with this program.
- #
- # Permission to use and disseminate this file for any use, except sale as
- # part of a commercial product, so long as this header remains intact, is
- # hereby granted by the author. As for any free software, this comes with
- # no guarantees of useablity. "It worked for me!"
- #
- # Write file .siggie to the standard output.
- #
- cat ~/.siggie
- #
- # Separate it from the random ~/.sig[0-9]* file with the usual "--" alone
- # on a line, written to the standard output.
- #
- echo "--"
- #
- # Inventory the files with names of format .sig[0-9]* into file ~/.sigtemp.
- #
- ls ~/.sig[0-9]* > ~/.sigtemp
- #
- # Use the number of lines in ~/sigtemp as a count of the .sig[0-9]* files,
- # and hand that count to "timemod" to get back a random number from 1 to
- # that count. Store that number in envronmental variable SIGPICK.
- #
- setenv SIGPICK `wc -l ~/.sigtemp | timemod`
- #
- # Create a one line awk program to pick the line with this line number from
- # .sigtemp. [Can you guess that my system doesn't support "head"? ;-)]
- #
- echo "NR==$SIGPICK {print}" > ~/.sigpick
- #
- # Use awk to dump this file name into a cat command's file list, and use this
- # cat command in turn to copy the random .sig[0-9]* to the standard output.
- #
- cat `awk -f ~/.sigpick ~/.sigtemp`
- #
- # That's it. Slow as molasses and ugly as sin, but it works. Sorry to use
- # csh instead of sh, but perhaps some kind person will translate this.
-