Archive for January, 2015

Awhile back, I posted a simple expect script for automating SSH sessions on a Mac.  Here is a similar script for automating telnet sessions.

As with the SSH script, create a text file using the naming convention of your choice and .sh for the extension.  In the file, type the following:

expect -c  ‘spawn telnet <ip-address>
expect “Username:”
send “<username>\r”
expect “password:”
send “<password>\r”

That is all you need to log in.  If you need to add an enable password, add the following to the script:

expect “>”
send “enable\r”
expect “password:”
send “<password>\r”

And there you have it.  If you want to log the output to a file, create a file to receive the output and then append the following to the last line:

| tee -a /path/filename.txt

Let me know if you find this helpful.


Read Full Post »

%d bloggers like this: