检测文件流中特定字符后触发 2015/07/03 13309 #!/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