4.2.2 Annotated examples
"banner"
on/usr/games
.;;; This function prints the output from a program that has been ;;; started with RUN-PROGRAM. On a heavily loaded system, pauses ;;; in program output can cause premature termination of this ;;; function. In this case the function can simply be called ;;; again to get the rest of the output. > (defun type-until-hung (stream) (do ((char (read-char-no-hang stream) (read-char-no-hang stream))) ((null char)) (write-char char))) TYPE-UNTIL-HUNG;; The shell is set to the stream that is used for standard input ;; and standard output for csh. The terminal remains the standard ;; error output stream. > (setq shell (run-program "csh" :input :stream :output :stream :wait nil)) #<Stream BUFFERED-STREAM 101BF73B>
;; Send a banner command to csh. > (format shell "/usr/games/banner test~%") NIL
> (force-output shell) NIL
;; Print the output from banner. > (type-until-hung shell) ##### ###### #### ##### # # # # # ##### #### # # # # # # # # # # # ###### #### # NIL
;; Send an erroneous command to the shell. > (format shell "unknown~%") NIL
> (force-output shell) NIL
> unknown: Command not found. ; This is standard output; ; it is not trapped. (type-until-hung shell) ; No output was sent to the NIL ; standard output.
;; Make csh exit. > (format shell "exit~%") NIL
;; Close the stream used for standard input and output. > (close shell) NIL
Generated with Harlequin WebMaker