Python subprocess: interacting with a shell script Python subprocess: interacting with a shell script shell shell

Python subprocess: interacting with a shell script


Try something like this (I have not tested it):

import pexpectchild = pexpect.spawn('yourprogram')while True:  found = child.expect ([r':$', r'\?$', pexpect.EOF])  if found == 0:    child.send('\n')  elif found == 1:    child.send('y\n')  else:  # EOF     return