Thank you very much.

José Luis Torre

2014-02-17 19:03 GMT+01:00 Nikodemus Siivola <>:
If you just want system(),

    (define-alien-routine system c-string (command c-string))

    (system "pwd")

but then you need to play games capturing output from fds -- or live
with the fact that eg. from Slime repl the output ends up in
*inferior-lisp* instead.

I would state Carlos' code along the lines of:

    (defun command (control &rest arguments)
        (with-output-to-string (stream)
          (sb-ext:run-program "/bin/sh"
                              (list "-c" (apply #'format nil control arguments))
                              :output stream :external-format :utf-8)))

  (command "pwd")

because mostly I at least want the results back in a string.

...but as you may be guessing by now, for most things
SB-EXT:RUN-PROGRAM is the tool you want, as it provides more options
for capturing output, etc.

There is, however, one thing for which system() is better than
RUN-PROGRAM: if you need to run a terminal program that expects to
take control of the screen. (Say vim.) Last time I checked SBCL and
RUN-PROGRAM don't handle the child process' terminal issues quite
right -- but calling system() instead works fine.

(I had a fix but it turned out to be slightly unportable, and I
dropped the ball instead of figuring out the portable solution.)


 -- nikodemus

Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
Sbcl-help mailing list

José Luis Torre