Previous Section Next Section Table of Contents Glossary Index

Chapter 9. Running Other Programs as Subprocesses

9.2. Examples

;;; Capture the output of the "uname" program in a lisp string-stream
;;; and return the generated string (which will contain a trailing
;;; newline.)
? (with-output-to-string (stream)
    (run-program "uname" '("-r") :output stream))
;;; Write a string to *STANDARD-OUTPUT*, the hard way.
? (run-program "cat" () :input (make-string-input-stream "hello") :output t)
;;; Find out that "ls" doesn't expand wildcards.
? (run-program "ls" '("*.lisp") :output t)
;;; Let the shell expand wildcards.
? (run-program "sh" '("-c" "ls *.lisp") :output t)

These last examples will only produce output if Clozure CL's current directory contains .lisp files, of course.


Previous Section Next Section Table of Contents Glossary Index