This list is amazing, I scratch my head, think and think then finally
post a question, maybe its the act of spelling it out, ps ax showed 2
x 'tail' processes, I am guessing zombies of previous attempts, killed
them, all works AOK now


On 10 June 2012 10:06, dave selby <dave6...@gmail.com> wrote:
> I have a simple script to tail a log file for an error string, it
> works AOK but there is an unexpected side effect, when I run it in a
> shell.
>
> if I
>
> echo "ERROR TEST" >> LOG
>
> in a separate shell, I get the following from the script
>
> ERROR TEST
> GOT YA :)
> ERROR TEST
>
> So it looks like I am getting stdout from the tail -f, and two copies
> of it ?, stdout should be piped to subprocess.stdout
>
> tail = subprocess.Popen(['tail', '-f', LOG_FILE], shell=False,
> stdout=subprocess.PIPE)
>
> for out in iter(tail.stdout.readline, ''):
>
>        out_str = out.rstrip('\n')
>
>        if out_str.find('ERROR') != -1:
>                print 'GOT YA :)'
>
>        time.sleep(1)
>
> Any ideas anyone ?
>
> Cheers
>
> Dave
>
> --
>
> Please avoid sending me Word or PowerPoint attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html



-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to