[Openmcl-devel] Capturing output from shell command

pekka pekka.niiranen at pp5.inet.fi
Sun May 13 21:08:58 UTC 2012


Dear Sir,

I reused some code from manual in order to study
command line arguments and calling external programs:

------------------------
(defun main (args)
    (format t "~a" args)
    (process-arguments)
    (quit))

(defun process-arguments ()
   (with-output-to-string (stream)
     (run-program "ls" '("-n") :wait t :output t)))

(let ((args ccl:*unprocessed-command-line-arguments*))
   (main args))

------------------------

It runs on OS X Lion terminal as follows:

$ ccl64 -l op.lisp -- one two three
total 16
-rw-r--r--  1 501  20  1280 May 13 19:11 clg.lisp
-rw-r--r--  1 501  20   270 May 13 23:49 op.lisp
(one two three)
$

All fine, except when I replace ":output t" with ":output stream".
How can I get the lines the shell directed to "stream" into a list?

------------------------
(defun main (args)
    (format t "~a" args)
    (process-arguments)
    (quit))

(defun process-arguments ()
   (with-output-to-string (stream)
     (run-program "ls" '("-n") :wait t :output stream)))
     ;; How to access data from the stream ????????????????

(let ((args ccl:*unprocessed-command-line-arguments*))
   (main args))

------------------------


-pekka-




More information about the Openmcl-devel mailing list