Innovation Unleashed

Recently, I was developing an script to automate telnet logins to do some transactions on other server. I tried a lot for two days but failed, on the third day I came across the package called expect which could fulfill my need.

All you need on your Linux Distro is a package called “EXPECT” which is freely available.

Here’s the sample code on how to automate Telnet Logins..


expect << EOF

set timeout 20

spawn telnet

expect “login: “

send “root\r”

expect “Password: “

send “123456\r”

expect “*#”

send “touch m12345\r”

expect “*#”

send “exit”



Note: the “\r” in every send command means the input from the user over & the data entered to be processed. (carriage return)

About these ads

Comments on: "Automating Telnet in a Bash Script" (5)

  1. very helpul, educational


  2. Thanks man, it was very usefull to reset a modem via telnet.

  3. egoncasteel said:

    Thank you that worked like a charm

  4. Thanks for finally writing about >Automating Telnet in a Bash Script | SunX’s Blog <Loved it!

  5. Hi there, I log on to your new stuff like every week.
    Your writing style is awesome, keep doing what you’re doing!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: