import sys import os import time command = sys.argv[1] file = open(sys.argv[2]) p = os.popen(command, 'w') for line in file: sys.stdout.write(line) sys.stdout.flush() time.sleep(1.0) p.write(line) p.flush() time.sleep(0.1) sys.stdout.flush()