Re: Capturing output from `system'

From: Erick Gallesio <eg_at_kaolin.unice.fr>
Date: Tue, 17 Oct 1995 18:40:40 +0000

> Christian Lynbech writes
> Is it possible to capture the output from commands run through
> `system'. The obvious solution of
>
> (with-output-to-string (lambda () (system command)))
>
> does not seem to work in STk 2.2 (SGI, Irix 5.3).
>
> I know of `exec' but then I loose the return value of the command and
> using `run-process' does not seem to change anything.
>
>
> Is there any way I can get the combined effects of `system' (return
> value) and `exec' (process output)? Or must I do some trickery with
> `exec', getting the shell-command to include the sub-command status in
> the output.
>
A quick hack could be:
(define (Christian-cmd command)
  (let ((p (run-process "/bin/sh" "-c" command :output :pipe)))
    (cons (port->string (process-output p)) (process-exit-status p))))

                -- Erick
Received on Tue Oct 17 1995 - 18:40:41 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST