Prev: Iteration through File.file? misses entries for which File.file?(entry) == true
Next: File.new ("write.txt", "w+") results in error
From: Roger Pack on 2 Aug 2010 10:01 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 2 Aug 2010 10:23 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 2 Aug 2010 10:25
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 |