[Sussex] Ruby file open question

Thomas Adam thomas at edulinux.homeunix.org
Mon Oct 31 15:29:54 UTC 2005


On Mon, Oct 31, 2005 at 10:30:20AM +0000, Ronan Chilvers wrote:
> Hi folks
>
> Any rubyers out there know if you can do this (Perl):

Yes.

> open(TAIL, "tail -f /var/log/messages");
>
> while(<TAIL>)
>
>  #do stuff
>
> } close(TAIL);
>
> but in ruby? I've found and played with the file-tail gem but its very
> slow to respond to file changes.

The problem with ruby-gems is that it's still in its infancy with
regards to supplying whats on the RAA [1].  That said, file-tail is the
way to go.  Note that you need to quantify what you mean by "slow" in
this context.  You can specify the delay for the checking of the file
change.  (see File::interval)

-- Thomas Adam

 [1] http://raa.ruby-lang.org
--  
"Try not to want people to like you too much, you'll just need more and
more flatteries to recharge your batteries." -- Jeffrey Lewis.




More information about the Sussex mailing list