From: Tom Spilman Date: 2001-05-27T00:40:04+09:00 Subject: [ruby-talk:15765] Re: Disabling stderr I've got a adequate fix that will work for me for now, but i'd really like to see this behavior controllable thru the ruby api. What i've done is wrap the call to 'rb_eval_string'... freopen( "nul", "a", stderr ); try { rb_eval_string( code.c_str() ); } catch ( ... ) { // retrieve exception info } freopen( "CONOUT$", "a", stderr ); I've only tried this on a windows system and it assumes that stderr was being directed to the console. Tom "Tom Spilman" wrote in message news:mhPP6.24451$CD5.13016619@news2.rdc2.tx.home.com... > Actually i've been perusing the source to the ruby parser and found that > 'rb_compile_error_append' is called when a compile time error occurs. > 'rb_compile_error_append' calls 'err_append' which when in eval mode dumps > the error via a call to fputs( s, stderr ). I could try the same technique > you described in C to keep ruby from doing this. Tom > > "J J" wrote in message > news:uO6P6.28544$BN6.1414115@newsread1.prod.itd.earthlink.net... > > How about: > > > > nulFile = File.open('nul', 'w') # UNIX: nulFile = > > File.open('/dev/null', 'w') > > STDERR = nulFile > > > > etc. > > > > Trouble is, exceptions don't seem to print to STDERR, or STDOUT. > > E.g. > > > > C:\john\ruby>ruby -e "q=File.open('nul','w'); STDERR=q; STDOUT=q; raise > > 'potty'" > > > > -e:1: warning: already initialized constant STDERR > > -e:1: warning: already initialized constant STDOUT > > -e:1: potty (RuntimeError) > > > > Regards, > > JJ > > > > -- > > Be Kind, Be Careful, Be Yourself > > -- > > Solid, reliable software at reasonable prices > > http://www.johnjohnsonsoftware.com > > > > > > "Tom Spilman" wrote in message > > news:b41P6.14655$CD5.7050932@news2.rdc2.tx.home.com... > > > Is there a way to keep Ruby from sending exception info to the > stderr > > > stream when i've embedded it into my application? Thanks. Tom > > > > > > > > > > > >