On Oct 24, 2005, at 1:16 PM, Tanner Burson wrote:

> Hi,
> I'm working through what seems like it should be a simple operation,
> re-routing STDERR to point elsewhere. I can do the following
>
> $stderr.reopen("/dev/null")
>
> which works fine. But what I'd like to do is capture that output, so I
> figured StringIO would be the way to go. According to the docs for  
> IO#reopen
> it can take an IO object as it's only parameter, and use that to re- 
> open,
> but when I do the following
>
> require 'stringio'
> str_io = StringIO.new
> $stderr.reopen(str_io)
>
> I get
>
> TypeError: can't convert StringIO into String
>
> any ideas?

$stderr = str_io

$stderr.puts 'hi'
warn 'warning'

$stderr.rewind
puts $stderr.read

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04