From: Robert Gleeson Date: 2009-12-12T01:08:16+09:00 Subject: Re: Redirecting standard output > I probably wasn't specific enough: sub processes which use exec to > overlay the image will not inherit redirection if you simply assign to > $stdout: > > 16:24:59 ~$ ruby19 -e '$stdout = File.open("log","w"); puts 123; > system("date")' > Fri Dec 11 16:25:05 WEST 2009 > 16:25:05 ~$ cat -n log > 1 123 > 16:25:08 ~$ ruby19 -e '$stdout.reopen("log"); puts 456; system("date")' > 16:25:14 ~$ cat -n log > 1 456 > 2 Fri Dec 11 16:25:13 WEST 2009 > 16:25:15 ~$ Ah! Okay. It makes sense now :-) Cool, I didn't know that. >> persist. > And exactly that is a problem: redirection does not take place for > whoever owns foo => it failed. "whoever owns foo => it failed?" ..? I don't see any difference between assigning $stdout and using $stdout.reopen in this case. foo = $stdout = File.open 'foo', 'w' foo = $stdout.reopen 'foo', 'w' They're both references to the same object. Can you elaborate or provide an example? Thanks. - Rob -- Posted via http://www.ruby-forum.com/.