- Reading stdout from a running script with Python
- # out.py
- def main():
- while True:
- print "test"
- time.sleep(10)
- main()
- # in.py
- text = sys.stdin.readline()
- print "hello " + text
- $ python out.py | python in.py
- $ arpwatch | python myscript.py
- import sys
- import time
- def main():
- while True:
- print "test"
- sys.stdout.flush()
- time.sleep(10)
- main()