https://pypi.python.org/pypi/pexpect
Pexpect allows easy control of interactive console applications.