Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Cisco IOS telnet login script? Is it possible?

My situation:

I have two terminal servers which are used to access lab equipment connected to their serial lines. Very handy as each lab device is accessed directly over a console line.

I want ot make a menu on one of the terminal servers, sos that I don't have to remember all of the line numbers. The menu is done, it works. But also I would like to make it even more handy, so I added the functunality to clear a tty line in case it's stuck for some reason or busy. Again, it works, just simple command aliases put in the menu. The problem is with the devices who are physically connected to the second terminal server, I have to first login to the terminal server and then execute clear line command and exit. That's the tricky part for me. So it has to be like a script, but within the Cisco IOS console. I can not use a macro, because it can only be applied in configuration mode. So my only option I guess is to use Tcl. Would it be possible to achieve that with Tcl? I'm not very experienced with scripts, but for the sake of automating this task, I'm willing to put few extra hours of effort...                  

Everyone's tags (4)
1 REPLY
New Member

Cisco IOS telnet login script? Is it possible?

All right,

I've been playing around with Tcl lately and I found what I need, but still cann not make Tcl script recognizing the output after Telnet session establishment, than sending the username and the password, and than the easy part, execute a command and loging off.

I found that in Tcl I can use the command "connect" and than establish a telnet session.

A sample script I'm banging my head with:

tclsh

proc telnet_switch{}{

      set success "Login successful!"

      set check "Username:"

      connect 172.26.160.6 telnet port 2046

       if {string equl $check}{

               puts "username\n"}

          else{ puts "password\n"}

       return $success

}

The command connect telnet port works on it's own, I've tested that. But how to make this simple script running? I've got an error like:

wrong # args: should be "proc name args body"

What I'm missing here?

1549
Views
0
Helpful
1
Replies