Python Pexpect Library
Pexpect is a pure Python module for spawning child applications, controlling them, and responding to expected patterns in their output. Pexpect works like Don Libes' Expect. Pexpct allows your script to spawn a child application and control it as if a human were typing commands. - Pexpect Read the Docs, https://pexpect.readthedocs.io/en/stable/index.html
Like the original Expect module by Don Libe, Pexpect launches or spawns another process and watches over it in order to control the interaction. Unlike the original Expect, it is entirely written in Python that does not quire TCL or C extensions to be compiled. This allows us to use the familiar Python syntax and its rich standard library in our code.
Installation
The installation of the pip and pexpect
packages is straightforward:
sudo apt-get install python-pip
sudo apt-get install python3-pip
sudo pip3 install pexpect
sudo pip install pexpect
Note
I am using pip3 for installing Python 3 packages while using PIP for installing...