Pexpect is a Python module for spawning child applications;
controlling them; and responding to expected patterns in their
output. Pexpect can be used for automating interactive applications
such as ssh, ftp, passwd, telnet, etc. Pexpect is pure Python.
