And if it's an ssh session you want to remote control, paramiko-expect is great, in particular the take_control method that lets your remote session be partly automated and partly controlled by the user running the outer program:
I like pexpect but it's next to useless on windows. If you are mostly doing ssh/ftp then paramiko is a useful (if heavy) pexpect replacement and works across platforms
Years back I worked on an automated test framework for small/mid-business scale cisco-clone routers that used Expect to drive the telnet CLI interface and put the routers through their paces.
I remember something a more senior engineer at the company told me: Expect is the best tool for when you need to get a job done the wrong way. (Using Expect was his idea, to be clear.)
Curious... your colleague said Expect was "the best wrong way", what would have been the "correct" way in your scenario? How would something like that best be done now? Ansible?
And modern software that does the same. Cisco AnyConnect VPN thing, for example. You can feed it a command file, but that doesn’t give you any error handling or logic to handle dynamic responses. Expect to the rescue!
It has a really mature and elegant way of handling the automation of command/response scenarios in connections to other machines.
I do similar stuff with .net now, but it's not as pretty. I wish there were a modern equivalent of Expect that as as nice.