home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 200.img / SCO386X3.TD0 / usr / spool / lp / model / network < prev    next >
Encoding:
Text File  |  1988-07-13  |  3.3 KB  |  123 lines

  1. :
  2. #    @(#) network.src 1.3 88/07/13 
  3. #
  4. #    Copyright (c) The Santa Cruz Operation, 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. #!    Remote printing over UUCP, MICNET or XENIX-Net
  10. #
  11. #    Lp interface script for remote XENIX network printing.
  12. #    This script can be used with UUCP, MICNET and XENIX-Net.
  13. #
  14. #    This script reads the file /usr/spool/lp/remote for lines
  15. #    in the format:
  16. #        name:    command
  17. #    Where <name> is the name by which the printer is called locally,
  18. #    and <command> is how lp(C) is to be run on the remote system.
  19. #    Typically, the <command> would be either:
  20. #        uux - lp -dprinter
  21. #    or:
  22. #        remote - lp -dprinter
  23. #    Note that the System V spooler is assumed used on the remote machine.
  24. #    In particular: 
  25. #    (1)  All options (-o...) passed to this script can be
  26. #        forwarded on in the same fashion, and
  27. #    (2)  The option -ob will cause the remote machine to
  28. #        suppress generating all banner pages.
  29. #    (3)  The <command> reads from its standard input, and this
  30. #        script can append on the additional flags described
  31. #        above to the end of <command>.
  32. #    Note that the IMAGEN laser printers generate their banner pages
  33. #    using a different technique and that a special version of this
  34. #    script is required.
  35. #
  36. #    Install this file as /usr/spool/lp/model/network.
  37. #    Then, to define remote printer <name>, edit /usr/spool/lp/remote
  38. #    as described above, and then, as superuser:
  39. #    (1)  /usr/lib/lpshut
  40. #    (2)  /usr/lib/lpadmin -pname -v/dev/null -mnetwork
  41. #    (3)  /usr/lib/accept name
  42. #    (4)  enable name
  43. #    (5)  /usr/lib/lpsched
  44. #    Remote printing on printer <name> should now be installed and
  45. #    working.  Jobs can be sent to that printer by "lp -dname ...".
  46.  
  47. PATH=/bin:/usr/bin
  48. mapping=/usr/spool/lp/remote
  49.  
  50. # get arguments
  51. printer=`basename $0`
  52. request=$1
  53. name=$2
  54. title=$3
  55. copies=$4
  56. options=$5
  57. shift; shift; shift; shift; shift
  58. files=$*
  59.  
  60. # set up options to pass to the remote printer spooler (as options for it)
  61. banner=yes
  62. lpflags=
  63. for i in $options; do
  64.     case $i in
  65.     b)    banner=no ;;
  66.     *)    lpflags="$lpflags -o$i" ;;
  67.     esac
  68. done
  69.  
  70. # map local printer name to machine and printer on that machine
  71. [ -r $mapping ] || exit 2
  72. set -- `grep -e "^$printer:" $mapping` || exit 3
  73. shift
  74. network=$*
  75.  
  76. # border around the banner
  77. x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  78.  
  79. (
  80.     [ "$banner" = yes ] && {
  81.         # get the local system id
  82.         if test -r /etc/systemid; then
  83.             sysid=`sed 1q /etc/systemid`
  84.         else
  85.             sysid=`uname -n`
  86.         fi
  87.  
  88.         # user = fifth field of /etc/passwd
  89.         user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  90.  
  91.         # nhead gets the value of BANNERS or 1 by default
  92.         nhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
  93.         [ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1
  94.  
  95.         # print the banner $nhead times
  96.         while    [ "$nhead" -gt 0 ]
  97.         do
  98.             echo "$x\n"
  99.             banner "$name"
  100.             echo "$x\n"
  101.             [ "$user" ] && echo "User: $user\n"
  102.             echo "Request id: $request\n"
  103.             echo "Printer: $printer\n"
  104.             date
  105.             echo "\nMachine: $sysid\n"
  106.             [ "$title" ] && banner $title
  107.             [ $nhead -ne 1 ] && echo "\f\c"
  108.             nhead=`expr $nhead - 1`
  109.         done
  110.     }
  111.  
  112.     # send the file(s) to the standard out $copies times
  113.     while    [ "$copies" -gt 0 ]
  114.     do
  115.         for file in $files
  116.         do
  117.             echo "\f\c"
  118.             cat "$file" 2>&1
  119.         done
  120.         copies=`expr $copies - 1`
  121.     done
  122. ) | $network -s -ob $lpflags
  123.