There is a program to interact with interactive command line tools exactly like the
expect. It is a specialized script shell, extending the on the scripting language
It is very powerful, but you may get away without learning everything about it. A very useful tool is
autoexpect, which can record an interactive session as an expect script. The recorded script is certainly helpful to understand the basics.
expect script can interact with an interactive program like
This can be combined with interaction of the user and the interactive program. Using the command
interact in an
expect script, the control can be given to the user temporarily.
While the user has control, the script still listens for events to take back the control, so practically, both the user and the script are interacting simultaneously with the program.