home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1564 / catsig next >
Encoding:
Text File  |  1990-12-28  |  2.3 KB  |  56 lines

  1. #! /bin/csh
  2. #
  3. #   csh script program "catsig", Copyright 1990 by Kent Paul Dolan, 94039-0755.
  4. #
  5. #   The purpose of catsig is to add to the end of a letter or news article
  6. #   (from the editor) a signature block consisting of the contents of
  7. #   home directory file ".siggie", and the contents of a "random" member of
  8. #   a list of home directory files with names of the form ".sig[0-9]*".  The
  9. #   .sig[0-9]* file names do not have to be sequentially numbered.
  10. #
  11. #   Uses:  from within mail, say "~r !catsig"; from within vi, say
  12. #   ":r !catsig".  Executables "catsig" and "timemod" must be in your
  13. #   executable file path list.
  14. #
  15. #   catsig uses two auxiliary files in the home directory, .sigtemp and
  16. #   .sigpick, sets a csh environmental variable SIGPICK, and requires 
  17. #   at least the old version of "awk", and program "timemod"by the current
  18. #   author, distributed with this program.
  19. #
  20. #   Permission to use and disseminate this file for any use, except sale as
  21. #   part of a commercial product, so long as this header remains intact, is
  22. #   hereby granted by the author.  As for any free software, this comes with
  23. #   no guarantees of useablity.  "It worked for me!"
  24. #
  25. #   Write file .siggie to the standard output.
  26. #
  27. cat ~/.siggie
  28. #
  29. #   Separate it from the random ~/.sig[0-9]* file with the usual "--" alone
  30. #   on a line, written to the standard output.
  31. #
  32. echo "--"
  33. #
  34. #   Inventory the files with names of format .sig[0-9]* into file ~/.sigtemp.
  35. #
  36. ls ~/.sig[0-9]* > ~/.sigtemp
  37. #
  38. #   Use the number of lines in ~/sigtemp as a count of the .sig[0-9]* files,
  39. #   and hand that count to "timemod" to get back a random number from 1 to
  40. #   that count.  Store that number in envronmental variable SIGPICK.
  41. #
  42. setenv SIGPICK `wc -l ~/.sigtemp | timemod`
  43. #
  44. #   Create a one line awk program to pick the line with this line number from
  45. #   .sigtemp.  [Can you guess that my system doesn't support "head"?  ;-)]
  46. #
  47. echo "NR==$SIGPICK {print}" > ~/.sigpick
  48. #
  49. #   Use awk to dump this file name into a cat command's file list, and use this
  50. #   cat command in turn to copy the random .sig[0-9]* to the standard output.
  51. #
  52. cat `awk -f ~/.sigpick ~/.sigtemp`
  53. #
  54. #   That's it.  Slow as molasses and ugly as sin, but it works.  Sorry to use
  55. #   csh instead of sh, but perhaps some kind person will translate this.
  56.