Thanks very much, Professor Ripley.
Reid Huntsinger
-----Original Message-----
From: ripley at stats.ox.ac.uk [mailto:ripley at stats.ox.ac.uk]
Sent: Tuesday, August 06, 2002 3:00 AM
To: Huntsinger, Reid
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] pipe and binary i/o (on Linux)
On Mon, 5 Aug 2002 ripley at stats.ox.ac.uk wrote:
> pipe predates readBin, and no one has seen a reason to do this before you.
However, gzfile should work, and bzfile *always* opens with "rb".
Here's
an example on RH7.2:
> zz <- gzfile("testbin.gz", "wb")
> writeBin(1:10, zz)
> close(zz)
> zz <- gzfile("testbin.gz", "rb")
> readBin(zz, integer(), 4)
[1] 1 2 3 4> readBin(zz, integer(), 6)
[1] 5 6 7 8 9 10> close(zz)
> zz <- pipe("gzcat testbin.gz", "rb")
Error in pipe("gzcat testbin.gz", "rb") : unable to open
connection
In addition: Warning message:
cannot open cmd `gzcat testbin.gz'
so pipe has problems, as on Linux popen does not respect "rb"
(although on
other platforms it seems to).
> It's an adequate fix.
On Linux, that is: Windows needs the "b". I've put a full fix in
R-devel.
>
> On Mon, 5 Aug 2002, Huntsinger, Reid wrote:
>
> > I often want to use "pipe" with "readBin" to read
(binary) data from the
> > standard output of a Perl or C program. For that I need
"pipe" to work
with> > the "open='rb'" option. It never worked for me, and
after a look at the
> > connections.c file, I see that in "pipe_open" the mode gets
passed
directly> > to "popen" (I'm using Linux on an Intel machine). Popen
doesn't know
"rb"> > and fails. I modified the pipe function in connection.c to pass only
the
> > first character of the mode. This seems to work (fingers crossed).
Then
I> > noticed gzfile has the same problem, but bzfile doesn't, and uses
the
same> > solution as I did for pipe. Can I assume that this is a correct fix?
Or
were> > there reasons that pipe and gzfile wouldn't allow "rb"?
> >
> > Thanks,
> >
> > Reid Huntsinger
>
> [irrelevant message deleted]
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272860 (secr)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-> r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information
of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be
confidential, proprietary copyrighted and/or legally privileged, and is intended
solely for the use of the individual or entity named on this message. If you
are not the intended recipient, and have received this message in error, please
immediately return this by e-mail and then delete it.
=============================================================================
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._