You'd want something more like this:

open(last_sim_log) do fh
    while !eof(fh)
        print(readline(fh))
    end
end


This does a couple of things:

   1. Use the open(...) do fh ... end construct to ensure file closing.
   2. Check for stream end using eof(fh) instead of catching an error.


On Fri, Sep 16, 2016 at 5:06 AM, <adrian_le...@hushmail.com> wrote:

> Thanks for the replies,
>
> For some reason only one chunk of data is printed even though the log is
> still being written to
>
>   fh = open(last_sim_log)
>   try
>     while true
>       print(readline(fh))
>     end
>   finally
>     close(fh)
>   end
>
> For readavailable(fh), I getting "no method matching
> readavailable(::IOStream)"
>
> Many Thanks
>
> Aidy
>
> On 9/15/2016 at 4:24 PM, "Stefan Karpinski" <ste...@karpinski.org> wrote:
> >
> >If you don't mind blocking when a complete line isn't available,
> >you can
> >just call readline(io) repeatedly.
> >
> >On Thu, Sep 15, 2016 at 7:57 AM, Steven G. Johnson
> ><stevenj....@gmail.com>
> >wrote:
> >
> >>
> >>
> >> On Thursday, September 15, 2016 at 7:11:55 AM UTC-4, Adrian
> >Lewis wrote:
> >>>
> >>> I have an active log and I wondered how I could `tail -f` this
> >without
> >>> running the Unix command?
> >>
> >>
> >> Open the file and repeatedly call `readavailable`
> >>
>
>

Reply via email to