[Top][All Lists]

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

Pipes and processes, stdin, stdout and stderr

From: Christopher Allan Webber
Subject: Pipes and processes, stdin, stdout and stderr
Date: Mon, 13 Apr 2015 19:17:41 -0500

Hello all,

Last night I was trying to do the equivalent of this:

  bash$ echo "foo" | sha512sum

in guile.  But I was unable to find a clear way to do it.

I tried something like:

(let* ((port (open-pipe*
              "sha256sum" "--binary")))
  (display "test me\n" port)
  (force-output port)
  (let ((result (drain-input port)))
    (close-port port)
    (car (string-split result #\space))))

Unfortunately, this just hangs forever at the drain-input.  I get the
same issue if I do (read-line port).

What I expected was that Guile would provide a way to access stdin,
stdout, stderr in a process as separate ports.  Python provides an API
more or less like this:

>>> from subprocess import Popen, PIPE
>>> proc = Popen("sha256sum", stdin=PIPE, stdout=PIPE)                          
>>> proc.stdin.write(b"foo")
>>> proc.stdin.close()
b'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -\n'

It looks like in the past there were discussions about doing something

It might be really nice if there was a way to access stdin, stdout, and
stderr as separate ports.  I might be willing to write some code for it,
if someone could point me in the right direction.  But I really don't
know where to look.

Is there a way to do this that I don't know?

Thanks for the help!
 - Chris

reply via email to

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