检测文件流中特定字符后触发

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/python
# coding: utf-8

from subprocess import Popen, PIPE

p1 = Popen("tail -f /var/log/1.txt", shell=True, stdout=PIPE)

while True:
    content = p1.stdout.readline()
    if 'end' in content:
        print 'end detected'
        break
    else:
        print content