From: Jan Svitok Date: 2007-03-03T07:28:33+09:00 Subject: Re: Ruby Noob: Using stderr, stdout, etc On 3/2/07, Rick DeNatale wrote: > On 3/2/07, Jenda Krynicky wrote: > > reed.adam@gmail.com wrote: > > > Thanks for the explanation Tim, that's exactly what I needed. I > > > didn't realize they would act differently under windows/unix - I think > > > I was stuck on imagining them as code-specific items because I wasn't > > > used to hearing about them in unix. > > > > > > Strangely enough, I'm ok as far as unix and pipe/redirection, and I've > > > been logging output of standard unix stuff to files for a couple of > > > years - just never knew specifically what the output was called. Go > > > figure. > > > > The thing to watch out for under Windows is that (at least on some > > versions) > > > > script.rb > results.txt > > > > doesn't work and you have to write > > > > ruby script.rb > results.txt > > > > This is caused by the fact that the cmd.exe has to use a different WIN32 > > API call to execute the script using the file extension mapping than > > what it would use for .exe and thatthe former doesn't preserve the > > STDxxx redirection. > > Also, although I haven't really kept up with windows, it used to be > able to redirect stdout, but not stderr. I was surprised when I learnt that since win2k it's possible to redirect stderr and even redirect stderr to stdout or vice versa, using progname 2> stderr.txt and progname 2&>1 You know, after all those years, maybe we'll be able to call cmd.exe a shell :D Other useful bits are: ^ is escape char - for escaping |, > etc. || and && work in windows as well So... reading help might be useful and surprising sometimes...