Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56305
| Date | 2013-10-07 11:52 +0200 |
|---|---|
| From | Andreas Perstinger <andipersti@gmail.com> |
| Subject | Re: How to streamingly read text file and display whenever updated text |
| References | (6 earlier) <l2rgjn$22h$1@ger.gmane.org> <CAPTjJmqvB9nk71yCVkdUisZPRk=Ouk7Es3QB53kBvtXGzxGYng@mail.gmail.com> <l2rhm9$90a$1@ger.gmane.org> <mailman.778.1381060337.18130.python-list@python.org> <65edfb89-52a7-4da3-85af-cc7c45601175@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.805.1381139555.18130.python-list@python.org> (permalink) |
On 07.10.2013 03:54, galeomaga@gmail.com wrote:
> https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing
>
For the readers who don't bother clicking on the link above: It's a
short video where the OP demonstrates how her/his usage of tail doesn't
work.
> no matter call tail directly in python or using the script of tail
> all failed
> it seems it can not read next line
In your video you use gedit to write some file and "tail -f <file>" to
follow it. But "tail -f" will follow the file descriptor. Usually,
editors like gedit won't save your changes to the original file but
create a new temporary file and rename it later to the original file
name after deleting the original one. Thus tail will follow an already
deleted file.
See also this blog post:
http://tech.shantanugoel.com/2009/12/23/continuous-monitor-tail-fails.html
For your example you will have to use "tail -F <file>" which will follow
the file name.
Alternatively you could write a simple script to simulate a continously
growing file like
import time
for i in range(1000):
with open("test.txt", "a") as f:
f.write(str(i) + '\n')
time.sleep(1)
which should work with "tail -f".
Bye, Andreas
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 00:38 -0700
Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 00:54 -0700
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 09:12 +0100
Re: How to streamingly read text file and display whenever updated text "James Harris" <james.harris.1@gmail.com> - 2013-10-05 09:06 +0100
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 09:14 +0100
Re: How to streamingly read text file and display whenever updated text Nobody <nobody@nowhere.com> - 2013-10-05 11:25 +0100
Re: How to streamingly read text file and display whenever updated text Joost Molenaar <j.j.molenaar@gmail.com> - 2013-10-05 13:02 +0200
Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 20:17 -0700
Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 14:28 +1100
Re: How to streamingly read text file and display whenever updated text Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-06 04:06 +0000
Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-06 01:49 -0700
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 11:36 +0100
Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:03 +1100
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 12:13 +0100
Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:15 +1100
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 12:31 +0100
Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:44 +1100
Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-06 18:54 -0700
Re: How to streamingly read text file and display whenever updated text Andreas Perstinger <andipersti@gmail.com> - 2013-10-07 11:52 +0200
Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 12:08 +0100
csiph-web