unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Pipes and processes, stdin, stdout and stderr
@ 2015-04-14  0:17 Christopher Allan Webber
  2015-04-14 16:41 ` Vladimir Zhbanov
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christopher Allan Webber @ 2015-04-14  0:17 UTC (permalink / raw)
  To: guile-user

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*
              OPEN_BOTH
              "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")
3
>>> proc.stdin.close()
>>> proc.stdout.read()
b'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -\n'

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

http://comments.gmane.org/gmane.lisp.guile.user/9300

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-17 12:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-14  0:17 Pipes and processes, stdin, stdout and stderr Christopher Allan Webber
2015-04-14 16:41 ` Vladimir Zhbanov
2015-04-14 17:45   ` Christopher Allan Webber
2015-04-15 21:38 ` Thien-Thi Nguyen
2015-04-16 15:34   ` Christopher Allan Webber
2015-04-17 19:44     ` Thien-Thi Nguyen
2015-04-18 15:44 ` Mark H Weaver
2015-05-17 12:14   ` Pipes and processes, stdin, stdout and stderr -- ./configure in Guile Jan Nieuwenhuizen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).