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

Simon Urbanek @|mon@urb@nek @end|ng |rom R-project@org
Tue Mar 17 01:33:59 CET 2020


FWIW if you're on unix, you can use named pipes (fifos) for that:

> system("mkfifo my.output")
> p = pipe("sed -l s:hello:oops: > my.output", "w")
> i = file("my.output", "r", blocking=FALSE, raw=TRUE)
> writeLines("hello!\n", p)
> flush(p)
> readLines(i, 1)
[1] "oops!"

Cheers,
Simon



> On 14/03/2020, at 6:26 AM, Greg Minshall <minshall using umich.edu> wrote:
> 
> hi.  i'd like to instantiate sed(1), send it some input, and retrieve
> its output, all via pipes (rather than an intermediate file).
> 
> my sense from pipe and looking at the sources (sys-unix.c) is that is
> not possible.  is that true?  are there any thoughts of providing such a
> facility?
> 
> cheers, Greg
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list