pexpect/pexpect

pexpect - A Python module for controlling interactive programs in a pseudo-terminal