How do I create a pipe between two processes in Guile?

699 views Asked by At

I want to create two process in Guile and send the output (stdout) from one of them as input (stdin) to the other.

Using the following example, how can this be done?

echo "foo bar" | wc

Output:

1       2       8
1

There are 1 answers

5
C. K. Young On BEST ANSWER

Yes, you can do this using open-output-pipe:

(let ((p (open-output-pipe "wc")))
  (display "The quick brown fox jumps over the lazy dog.\n" p)
  (close-pipe p))

This is equivalent to echo "The quick brown fox jumps over the the lazy dog." | wc (including echo's implicit newline because I'm that particular, lol).

There is, of course, an open-input-pipe analogue. Read the Pipes section of the Guile manual for more details.