Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:text': 0.05; 'received:192.168.178': 0.07; 'rename': 0.07; 'subject:file': 0.07; 'subject:How': 0.10; 'python': 0.11; 'changes': 0.15; "'\\n')": 0.16; 'andreas': 0.16; 'bye,': 0.16; 'descriptor.': 0.16; 'received:192.168.178.20': 0.16; 'simulate': 0.16; 'subject: \n ': 0.16; 'url:file': 0.16; 'wrote:': 0.18; 'later': 0.20; 'seems': 0.21; 'example': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'file.': 0.24; 'script': 0.25; 'header:In-Reply- To:1': 0.27; 'thus': 0.29; "doesn't": 0.30; 'work.': 0.31; 'file': 0.32; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'next': 0.36; 'should': 0.36; 'growing': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'deleting': 0.60; 'new': 0.61; 'matter': 0.61; 'simple': 0.61; 'save': 0.62; 'email addr:gmail.com': 0.63; 'name': 0.63; 'temporary': 0.65; 'readers': 0.68; 'clicking': 0.73; 'demonstrates': 0.84; 'subject:read': 0.84; 'url:edit': 0.84; 'url:tech': 0.84; 'url:23': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=f5dc67BAxZ/Him2rGvVoL44/89p0+sdXvs5acbElT30=; b=ytve7vba66MKfM2dvP7ZvXRgjWXP0nuZiwshmU1NxSnPRZoaKkvtJDyz6SXfTinqay /e/U4WXeC9/y03Fww4PGfBoT77DPCxd3fFDDdRpkEerJn5HCa3tMQisuXWn6mcG9sYQN xVrocSGji3O9LGWY0UfDncoHhPSS8yhFduTdluq++EInioIeGRbJQAI0sWyTcwyFY8fx 4gacKm1SLv8MVinn6DvphP2Z2LHlXS6AWZaAKH+tRqug6lvifr9dPEn2PCdtSAyP7sDN QAr/zQobEylesRxRMhFFwoXzlBo5qOAJIx/TWrOU7SJW0eb1ZHjV5vk7GeTGK9eH0J4d fKsg== X-Received: by 10.204.61.195 with SMTP id u3mr798156bkh.43.1381139548464; Mon, 07 Oct 2013 02:52:28 -0700 (PDT) Date: Mon, 07 Oct 2013 11:52:25 +0200 From: Andreas Perstinger User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How to streamingly read text file and display whenever updated text References: <04ee91f9-1cbf-4364-bca3-da25aa4db45f@googlegroups.com> <5250e1d6$0$29984$c3e8da3$5496439d@news.astraweb.com> <65edfb89-52a7-4da3-85af-cc7c45601175@googlegroups.com> In-Reply-To: <65edfb89-52a7-4da3-85af-cc7c45601175@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381139555 news.xs4all.nl 15883 [2001:888:2000:d::a6]:52958 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56305 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 " 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 " 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