Skip to content
Prev 58158 / 63424 Next

pipe(): input to, and output from, a single process

I am not sure if `pipe()` works for this, but if it turns out that it
does not, then you can use the processx package, e.g.:
[1] "foobxr\n"

The `-l` sed flag is to make sed line-buffered, otherwise it is will
not produce output until there is enough.

`$write_input()` and `$read_output()` are not easy to program, in particular:
* `$write_input()` returns the chunk of data that it hasn't managed to
write into the pipe. You need to call `$write_input() again, with this
data next, usually.
* `$read_output()` returns an empty string if there is no data to
read, so typically you want to call `p$poll()` first, to make sure
that there is something to read.
* `$read_output()` might not read whole lines, so maybe
`$read_output_lines()` is better for you.
* Close the stdin of the process if you want to quit cleanly:
`close(p$get_input_connection())`.
* There is currently no way to poll the input side of the pipe. :(

HTH, Gabor
On Mon, Mar 16, 2020 at 11:31 AM Greg Minshall <minshall at umich.edu> wrote: