[gambit-list] Process stdout redirection

Adam adam.mlmb at gmail.com
Tue Mar 20 21:08:26 EDT 2018


2018-03-21 9:03 GMT+08:00 C K Kashyap <ckkashyap at gmail.com>:

> Thanks Adam,
>
> I was wondering then, what would be a better way to do this -
> (with-output-to-file "output.txt"
>   (lambda ()
>     (display
>      (call-with-input-process
>       program
>       (lambda (port)
> (read-line port #f))))))
>
> If I understand it right, this requires an extra read and write. If Gambit
> lets the port be overridden by the surrounding with-output-to-file, perhaps
> the whole thing could be achieved without the extra read and write. Hence
> my question was more about whether there is a problem with this approach
> that I am not able to see.
>

If you're trying to achieve "/bin/sh -c \"program > output.txt\"", then
first that's not what you're doing here, and second, you would benefit of
using read/write-subu8vector for the forwarding as it's faster. Or you
could ask the OS to do it using |shell-command|.

You need to clarify your problem specification and code example for anyone
to be able to give you more guidance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20180321/1a493de6/attachment.htm>


More information about the Gambit-list mailing list