- #!/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().strip()
- if 'end' in content:
- print 'end detected'
- break
- else:
- print content
- #该片段来自于http://www.codesnippet.cn/detail/2703201512008.html
来源: http://www.codesnippet.cn/detail/2703201512008.html