Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My favorite thing in the Tcl ecosystem was "Expect". It's a tool you can use to automate ssh/telnet/serial connections to other machines.

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.



Python's pexpect is very nice: https://pexpect.readthedocs.io/en/stable/

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:

https://github.com/fgimian/paramiko-expect/blob/master/param...


pexpect is nice, and basically replicates expect functionality in Python. I remember when using it it had few minor bugs, but maybe that improved.


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?


Expect is an amazing tool for dealing with old hardware that _insists_ on interactive prompts instead of CLI flags.


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!


Also great for automated tests of interactive functionality in your own projects.


I also love Expect and still use it. It makes a lot of what used to be "fingerbone tasks" go super quick.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: