[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hardcopy with TCP/IP? Sure thing.



Assuming that your unix machine's tcp software has an rexec deamon
(usually called /etc/rexecd), then the following will do the job.  You
load this file into your Lisp machine and be sure it is saved into the
world.  

Another thing you will have to do is add a service to the unix
machines host entry in the namespace.  This service is

HARDCOPY <tcp-medium> UNIX-REXEC

where <tcp-medium> is whatever the medium string for TCP/IP is called.
I forget at the moment, and am at home.  This one is set up to use a
special account, which is associated with an ersatz shell allowing only
lpr and a couple of other harmless commands (sort of like uucico).
This way, its password can be quasi-common-knowledge.  I recommend you
follow this practice as well --- I tried it with passwords and the
user's machine account, but the incessant pop-up windows ran me bananas.

You may want to customize the command strings and the harunching around
of argument options, but this should be pretty easy to figure out.

Charles Buckley                         uucp: mcvax!ethz!ceb
                                        earn: BUCKLEY@CZHETH5A
                                        arpa: mcvax!ethz!ceb@uunet.uu.net
                                              cb@sail.stanford.edu
Integrated Systems Laboratory           
ETH-Zentrum                             

Postal Address:
Wiesgasse 9
CH-8304 Wallisellen     
Tel: +411 256 52 45

---- cut here ----
;;; -*- Mode: LISP; Package: HARDCOPY; Base: 10; Syntax: Common-lisp -*-

;;
;;        hardcopy-through-rexec.lisp
;;
;;        C. Buckley
;;        Integrated Systems Laboratory
;;        Swiss Federal Institute of Technology
;;        Zurich
;;
;;        13 October 1987
;;
;;        Since there are no LGP servers for TCP on unix, we simulate
;;        the same thing using the rexec service, and the lpr
;;        command.  Ugh.  This version uses a special account called
;;        lispm, with password conscarcdr, which can only print files.
;;

;;
;;        We here define the protocol to generate the hardcopy 
;;        stream using rexec.
;;

(net:define-protocol :unix-rexec (:hardcopy :byte-stream)
  (:desirability .8)
  (:invoke (path)
   (let* ((host (neti:service-access-path-host path))
          (args (neti:service-access-path-args path))
          (options (second args))
          (plist (locf options))
          (file-name (get plist :title))
          (no-banner-page (not (get plist :print-cover-pages)))
          (copies (get plist :copies))
          (printer-name (string-downcase (send (send (first args) :name)
                                               :string)))
          (command-string
            (string-append "lpr "
                           (if printer-name
                               (string-append "-P" printer-name " ") "")
                           (if file-name
                               (string-append "-J \"" (string file-name) "\" ")
                               "")
                           (if no-banner-page "-h " "")
                           (if (and (numberp copies) (> copies 1))
                               (format nil "-\#~d " copies) "")
                           "-C \"" (string host) "\""))
          (stream (neti:get-connection-for-service path :characters nil)))
       (unwind-protect
           (progn
             (send stream :string-out (string-to-ascii "0"))
             (send stream :tyo 0)
             (send stream :string-out (string-to-ascii "lispm"))
             (send stream :tyo 0)
             (send stream :string-out (string-to-ascii "conscarcdr"))
             (send stream :tyo 0)
             (send stream :string-out (string-to-ascii command-string))
             (send stream :tyo 0)
             (send stream :force-output)
             (if (zerop (send stream :tyi))
                 (progn
                   (send stream :string-out (string-to-ascii "%!"))
                   stream)
                 (progn
                   (error "REXEC error from ~A: ~A" host
                          (ascii-to-string
                            (with-output-to-string (s)
                              (stream-copy-until-eof stream s))))
                   (send stream :close :abort)
                   nil)))))))