From: Roger Pack on
I assume the doc's are "just wrong" when they say you can access an
IO.popen with any mode you'd like?

http://ruby-doc.org/core/classes/IO.html#M002242

>> IO.popen("gocr", "rw")
ArgumentError: invalid access mode rw

Is this expected?
-r
--
Posted via http://www.ruby-forum.com/.

From: Brian Candler on
Roger Pack wrote:
> I assume the doc's are "just wrong" when they say you can access an
> IO.popen with any mode you'd like?
>
> http://ruby-doc.org/core/classes/IO.html#M002242
>
>>> IO.popen("gocr", "rw")
> ArgumentError: invalid access mode rw
>
> Is this expected?

Yes. It doesn't say "any mode you'd like"; it says "any of the modes
listed in the description for class IO" - that is, any *valid* mode :-)

You're probably looking for mode "r+" or "a+"

http://ruby-doc.org/core/classes/IO.html
--
Posted via http://www.ruby-forum.com/.

From: Jean-Julien Fleck on
Hello Roger,

> http://ruby-doc.org/core/classes/IO.html#M002242
>
>>> IO.popen("gocr", "rw")
> ArgumentError: invalid access mode rw

When I want to read and write from the IO.popen'ed command, I use

IO.popen(cmd, "r+")

but I do not remember from which source I found I had to use "r+"
rather than the more expected "rw"

Cheers,

--
JJ Fleck
PCSI1 Lycée Kléber