问题
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:
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.
来源:https://stackoverflow.com/questions/18436981/how-do-i-create-a-pipe-between-two-processes-in-guile