[Rd] Reading exit code of pipe()

Kevin Ushey kevinushey at gmail.com
Thu May 14 07:27:23 CEST 2015

Hi Jeroen,

I think `pipe` might just be returning the status code of the
underlying command executed; for example, I get a status code of '0'
when I test a pipe on `ls`:

    conn <- pipe("ls")
    stream <- readLines(conn)

Similarly, I get an error code if I try to `ls` a non-existent
directory (512 in my case), e.g.

    conn <- pipe("ls /no/path/here/sir")
    stream <- readLines(conn)

So maybe `cat` just doesn't set a status code, and so there's nothing
for R to forward back (ergo -- NULL)?


On Wed, May 13, 2015 at 5:24 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:
> Is there a way to get the status code of a pipe() command? The
> documentation suggests that it might be returned by close, however
> this does not seem to be the case.
>   con <- pipe("cat /etc/passwd", "r")
>   stream <- readLines(con, n = 10)
>   err <- close(con)
>   print(err)
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list