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.
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
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
wrote:
>
>
> On Thursday, September 15, 2016 at 7:11:55 AM UTC-4, Adrian Lewis wrote:
>>
>> I have an active log
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`