How to redirect output to another directory?


(Kurt Euler) #1

All-

The last line of the following code writes a bunch of files in the current directory (…/ruby/bin).

 content = File.new("template1.txt").read
 fs = File.new("fiddle.sticks").read
 IO.foreach("packages.txt") { |x|
   field = x.chop.split(':')
   content2 = content
   content2.gsub!(/<release_num>/, fs)
   File.new(field[0],"w+").write(content2)
 }

Question: How can I redirect the output to the subdirectory “…/ruby/bin/output”?

I would have thought that I could rewrite the last line thus:

   File.new(field[0],"w+").write("./output/" << content2)

But this has no effect on the output.

Thanks!

-Kurt Euler