home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume27 / psf3 / part04 / psfunix.LP < prev    next >
Text File  |  1992-01-20  |  2KB  |  116 lines

  1. :
  2. # $Id: psfunix.LP,v 3.1 1991/11/27 06:02:58 ajf Exp ajf $
  3. #  Postscript serial or parallel printer using psf filters
  4. #
  5. #    "make scripts" will use sed to replace "BINARY" with
  6. #        the binary library directory name such as /local/bin.
  7.  
  8. # The following parameters are passed from "lp" at print time.
  9.  
  10. printer=`basename $0`
  11. request=$1
  12. name=$2
  13. title=$3
  14. copies=$4
  15. options=$5
  16. shift; shift; shift; shift; shift
  17.  
  18. # Modify the following for required stty settings.
  19.  
  20. stty onlcr ixon ixoff 0<&1
  21.  
  22. # get the banner option from the configuration file.
  23. # see if the user is allowed to override the banner spec.
  24. # The "Banner: on" and "Banner: on:Always" can be specified by lpadmin.
  25. # The "Banner: off" must be manually edited into the configuration file.
  26.  
  27. banner="yes"
  28. banopt=`sed -n 's/^Banner: *\(.*\).*$/\1/p' /usr/spool/lp/admins/lp/printers/$printer/configuration`
  29. mustbanner="no"
  30. for i in ${banopt}
  31. do
  32.     case "${i}" in
  33.     
  34.     on)        banner="yes"
  35.             mustbanner="no"
  36.             ;;
  37.     on:Always)    banner="yes"
  38.             mustbanner="yes"
  39.             ;;
  40.     off)        banner="no"
  41.             mustbanner="no"
  42.             ;;
  43.     *)        banner="yes"
  44.             mustbanner="no"
  45.             ;;
  46.     esac
  47. done
  48.  
  49. option_list=$options
  50. options=
  51. for i in ${option_list}
  52. do
  53.     case "${i}" in
  54.  
  55.     *@*)    rname="${i}"
  56.         ;;
  57.     nobanner)
  58.         case "${mustbanner}" in
  59.         yes)    ;;
  60.         *)    banner="no"
  61.             ;;
  62.         esac
  63.         ;;
  64.     banner)
  65.         banner="yes"
  66.         ;;
  67.     *)
  68.         options="${options} ${i}"
  69.         ;;
  70.     esac;
  71. done
  72.  
  73. today=`date`
  74.  
  75. [ "$title " = " " ] && {
  76.     title=`basename $1`
  77. }
  78.  
  79. [ "$banner" = "yes" ] && {
  80.  
  81. #    get the machine name uname.
  82.     sysid=`uname -n`
  83.  
  84. #    get the user name from the GCOS field in /etc/passwd
  85.     user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  86.  
  87. #    user is on remote system
  88.     case $rname in
  89.     [0-z]*) name=$rname
  90.         ;;
  91.     esac
  92.  
  93.     BINARY/psfbanner "$name" "$user" "$request" "$printer" "$options" "$today" "$sysid" "$title" -g PAGETYPE -u DEFFILE
  94. }
  95.  
  96. #    If the file looks like it is in postscript, then psffilter
  97. #    copies the file to the printer.  (unless -z is specified)
  98. #    The "$options" are passed by lp with  -o"opions"
  99.  
  100. #    To ensure that file names do not push off the date stamp,
  101. #    you might wish to use:
  102. #
  103. #        fname=`basename $file`
  104. #        BINARY/psffilter $options "$fname" <$file 2>&1
  105.  
  106. files="$*"
  107. while    [ "$copies" -gt 0 ]
  108. do
  109.     for file in $files
  110.     do
  111.         BINARY/psffilter -g PAGETYPE $options "$file" <$file 2>&1
  112.     done
  113.     copies=`expr $copies - 1`
  114. done
  115. exit 0
  116.