Doan, Alex
4/18/2007 10:14:00 PM
Can someone explain to me why the following raise an error? (is this
something with File::Tail::Logfile.open not closing the file upon exit?)
require 'file/tail'
File::Tail::Logfile.open('output.txt', :backward => 10, :return_if_eof
=> true ) do |log|
log.tail { |line| puts line}
end
File.rename('output.txt', 'output2.txt')
Output:
C:/alex/work/build_process/scripts/test.rb:19:in `rename': Permission
denied - output.txt or output2
txt (Errno::EACCES)
from C:/alex/work/build_process/scripts/test.rb:19
============================================
While this work:
require 'file/tail'
fh = File::Tail::Logfile.open('output.txt', :backward => 10,
:return_if_eof => true )
fh.tail { |line| puts line }
fh.close
File.rename('output.txt', 'output2.txt')