[Openmcl-devel] Got it (was: Capturing output from shell command)

pekka pekka.niiranen at pp5.inet.fi
Mon May 14 14:54:20 PDT 2012


Forget it,

I managed to solve the problem with the following code:

---------------------------
(defun main (args)
   (if args
       (format t "~&Arguments were: ~a" args))
   (system "ls" "-n")
   (quit))

(defun system (cmd &optional args)
   (with-input-from-string
       (istream (with-output-to-string (ostream)
         (run-program cmd (list args) :output ostream)))
     (copy-stream istream)))

(defun copy-stream (in)
   (loop for line = (read-line in nil nil)
        while line
        do (format t "~%~a" line)))

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

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

-pekka-




More information about the Openmcl-devel mailing list