home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 200.img / SCO386X3.TD0 / usr / spool / lp / model / dumb < prev    next >
Encoding:
Text File  |  1988-05-17  |  1.6 KB  |  77 lines

  1. :
  2. #    @(#) dumb.src 1.6 88/05/13 
  3. #
  4. #    Copyright (C) The Santa Cruz Operation, 1985, 1986.
  5. #    This Module contains Proprietary Information of
  6. #    The Santa Cruz Operation, Microsoft Corporation
  7. #    and AT&T, and should be treated as Confidential.
  8. #
  9. #!    Dumb serial or parallel printer
  10. #    Options: lp -ob   no banner
  11. #
  12. printer=`basename $0`
  13. request=$1
  14. name=$2
  15. title=$3
  16. copies=$4
  17. options=$5
  18. shift; shift; shift; shift; shift
  19.  
  20. # If it is necessary to change the baud rate or other stty settings for
  21. # your serial printer modify the following line:
  22. stty ixon ixoff 0<&1
  23.  
  24. # border around the banner
  25. x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  26.  
  27. banner=yes
  28. for i in $options; do
  29.     case $i in
  30.     b)    banner=no ;;
  31.     esac
  32. done
  33.  
  34. [ "$banner" = yes ] && {
  35.     # get the local system id
  36.     if test -r /etc/systemid; then
  37.         sysid=`sed 1q /etc/systemid`
  38.     else
  39.         sysid=`uname -n`
  40.     fi
  41.  
  42.     # user = fifth field of /etc/passwd
  43.     user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  44.  
  45.     # nhead gets the value of BANNERS or 1 by default
  46.     nhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
  47.     [ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1
  48.  
  49.     # print the banner $nhead times
  50.     while    [ "$nhead" -gt 0 ]
  51.     do
  52.         echo "$x\n"
  53.         banner "$name"
  54.         echo "$x\n"
  55.         [ "$user" ] && echo "User: $user\n"
  56.         echo "Request id: $request\n"
  57.         echo "Printer: $printer\n"
  58.         date
  59.         echo "\nMachine: $sysid\n"
  60.         [ "$title" ] && banner $title
  61.         echo "\f\c"
  62.         nhead=`expr $nhead - 1`
  63.     done
  64. }
  65.  
  66. # send the file(s) to the standard out $copies times
  67. while    [ "$copies" -gt 0 ]
  68. do
  69.     for file
  70.     do
  71.         cat "$file" 2>&1
  72.         echo "\f\c"
  73.     done
  74.     copies=`expr $copies - 1`
  75. done
  76. exit 0
  77.