home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 21 PDrivers / 21-PDrivers.zip / psnupos2.zip / psnup.bongo < prev    next >
Text File  |  1995-01-24  |  2KB  |  82 lines

  1. #!/bin/sh
  2. #
  3. # @(#)psnup    1.4 9/1/90 (cc.utexas.edu) /usr/share/src/public/postscript/psnup/SCCS/s.psnup
  4. #
  5.  
  6. # Psnup -- take a postscript file and filter it to give n-up printing.
  7. # The real work is done by the nup.pro and nup.pre postscript scripts
  8. # supplied by Ned Batchelder at U. Penn. <ned@UPenn.CSNet>.
  9. #
  10. # Roy Smith <phri!roy> Wed Apr 22 13:33:39 EST 1987.
  11.  
  12. # Where to find the prologue and epilogue files.
  13. lib=/usr/local/lib/ps
  14. prologue=$lib/nup.pro
  15. epilogue=$lib/nup.epi
  16.  
  17. # Default parameters.
  18. Nup=2        # 2 spots per page.
  19. Reverse=false    # No reversal (upper left to lower right).
  20. Start=0        # First page goes in spot number 0.
  21. File=""        # No file (read from standard input).
  22.  
  23. # Step through arguments.
  24. while [ -n "$1" ]; do
  25.     case "$1" in
  26.         -n)    case "$2" in
  27.                2|4|8|16) Nup="$2"
  28.                          ;;
  29.                *)        echo psnup: -n must be 2, 4, 8, or 16 >&2
  30.                          exit 1
  31.                          ;;
  32.             esac
  33.             shift
  34.             ;;
  35.         -r)    Reverse=true
  36.             ;;
  37.         -s)    Start="$2"
  38.             ;;
  39.         *)    break
  40.             ;;
  41.     esac
  42.     shift
  43. done
  44. File="$1"    # if any arguments left, use the first as a file name.
  45.  
  46. #
  47. # Before we begin, make sure all the files are readable.
  48. #
  49. if [ ! -r $prologue ]
  50. then
  51.     echo psnup: error reading $prologue, call for help. >&2
  52.     exit 1
  53. fi
  54. if [ -n "$File" -a ! -r "$File" ]
  55. then
  56.     echo psnup: "$File" unreadable or non-existant. >&2
  57.     exit 1
  58. fi
  59. if [ ! -r $epilogue ]
  60. then
  61.     echo psnup: error reading $epilogue, call for help. >&2
  62.     exit 1
  63. fi
  64.  
  65. #
  66. # Emit the prologue, inserting parameters along the way.
  67. #
  68. sed    -e "s/@#@Pages@#@/$Nup/" \
  69.     -e "s/@#@Rev@#@/$Reverse/" \
  70.     -e "s/@#@Start@#@/$Start/" \
  71.     $prologue
  72.  
  73. #
  74. # Emit the file.  Note that if there was no file name, $File
  75. # is the null string and this just copies stdin to stdout.
  76. cat $File
  77.  
  78. #
  79. # Emit the epilogue
  80. #
  81. cat $epilogue
  82.