Skip to content

Instantly share code, notes, and snippets.

@dbrgn
Created December 1, 2012 22:47
Show Gist options
  • Save dbrgn/4185712 to your computer and use it in GitHub Desktop.
Save dbrgn/4185712 to your computer and use it in GitHub Desktop.
from subprocess import Popen, PIPE, STDOUT
import time
def process_line(line):
print 'New line: "%s"' % line.strip('\n')
proc = Popen(['bash', 'print_lines.sh'], stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
while True:
line = proc.stdout.readline()
if line != '':
process_line(line)
else:
break
echo "Line 1"
sleep 1
echo "Line 2" 1>&2;
sleep 1
echo "Line 3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment