guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read a string output with `open-input-pipe` on Mac OS?


From: Zelphir Kaltstahl
Subject: Re: How to read a string output with `open-input-pipe` on Mac OS?
Date: Tue, 10 Oct 2023 10:41:48 +0000

On 10/10/23 02:49, Panisuan Chasinga wrote:
Hi list, I want to read a string output using `ice-9/popen/open-input-pipe`
but somehow always got an empty string. Here is my test code:


(use-modules (ice-9 popen))
(use-modules (ice-9 textual-ports))

(define (test-read-port)
   (let* ((port (open-input-pipe "ls"))
            (str (get-string-all p)))
      (close-port p)
      str))


I was able to read from a file with `open-input-file`, but not
`open-input-pipe` with any command. Running `(system "ls")` seemed to work
just fine.

Hello Panisuan,

perhaps this code can help you as well: https://notabug.org/ZelphirKaltstahl/guile-examples/src/22bf7be3ae46a7b520c1482ab80985bfbdae6eb6/input-output/stdout-stderr.scm

It handles also error output.

Best regards,
Zelphir

--
repositories: https://notabug.org/ZelphirKaltstahl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]