Expect

Expect is a nice little Unix program. It is meant to automate UNIX commands that never meant to be automated. I used expect to automate a ssh session using username/password rather than a host key.  The “normal” way to automate ssh sessions is to generate public/private ssh  host keys and distribute the public host key to your target servers.  That way you would never have to enter your password in order to log into a remote server.  I didn’t have this option as I wanted to “leave no footprints” on my target servers.

I’ve been wanting to learn expect for years but this was an opportunity to do so in the context of a project.  I had more than  30 servers to log into , examine  some logs and go on to the next server.  Using “expect” I was able to do this in less than 30 seconds vs. 1/2 day doing the same thing manually.

 


Comments

Expect — 1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.