From: Paul Melis Date: 2002-12-01T00:58:55+09:00 Subject: Re: catch stderr "Shannon Fang" wrote in message news:20021129220610.990B.XRFANG@hotmail.com... > Hi, > > I have some question about catching stderr output in ruby... Please read > the following simple code. > > STDERR.reopen STDOUT > result=`net use abc` > print "res=", result > > while abc is not available on my LAN. I didn't succeed in catch the > stderr output to my program. Since you seem to be on windows, perhaps that is screwing up the redirect stuff. Windows is not very good at the unix ways of I/O streams. One way of capturing stderr (or actually redirecting) is using the "redir" utility included in DJGPP (included in ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/djdev203.zip). It allows you to redirect stderr to stdout (or a file), so you can do irb(main):001:0> res = `redir -eo net use abc` "System error 67 has occurred.\n\nThe network name cannot be found.\n\n" irb(main):002:0> res "System error 67 has occurred.\n\nThe network name cannot be found.\n\n" Good luck, Paul