From: Ryan Leavengood Date: 2006-05-07T14:24:58+09:00 Subject: Re: Output redirection in windows It works for me on the latest One-Click: C:\_Ryan\downloads>irb irb(main):001:0> system('echo "hello world!" > hello.txt') => true irb(main):002:0> exit C:\_Ryan\downloads>type hello.txt "hello world!" Another option is to do the redirection yourself: File.open('output.txt', 'w') do |file| IO.popen('dir') do |pipe| pipe.each do |line| file.print line end end end Ryan On 5/7/06, Aditya Mahajan wrote: > I am using the one-click installer on windows (RC2). I can not get > output redirection to work with Kernel.system. Consider the following code > > F:\tmp\cont-test\test>cat test.rb > def test(command) > puts command > puts Kernel.system(command) > puts "---------------------------" > end > > test("mpto mp-test-01.mp") > test("mpto mp-test-01.mp > mp-test-01-test.tex") > > > mpto.exe is a helper program that comes with metapost and is part of most tex > distributions. It is included in my path environment. I have a file > mp-test-01.mp in the current directory. mpto scans the .mp file and outputs on > stdout. I want to redirect that output to a file. But > does not work. > > Running this program gives > > F:\tmp\cont-test\test>ruby test.rb > mpto mp-test-01.mp > \gdef\mpxshipout{\shipout\hbox\bgroup > \setbox0=\hbox\bgroup} > \gdef\stopmpxshipout{\egroup \dimen0=\ht0 \advance\dimen0\dp0 > \dimen1=\ht0 \dimen2=\dp0 > \setbox0=\hbox\bgroup > \box0 > \ifnum\dimen0>0 \vrule width1sp height\dimen1 depth\dimen2 > \else \vrule width1sp height1sp depth0sp\relax > \fi\egroup > \ht0=0pt \dp0=0pt \box0 \egroup} > \mpxshipout% line 2 mp-test-01.mp > This is a test\stopmpxshipout > \end{document} > true > --------------------------- > mpto mp-test-01.mp > mp-test-01-test.tex > false > --------------------------- > > system "mpto ..." executes correctly (the true after \end{document}) > while system "mpto ... > ...." fails. No mp-test-01-test.tex file is created. > > When I give the same commands from cmd.exe they work. I am confused why > something as simple as output redirection is not working. What is the correct > way to do this? > > Thanks, > Aditya > >