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

Using EEM to telnet to switches and execute commands

Can EEM telnet to other switches.

It doesn't seem to work and when you run debug it drops out at the password for telnet.

I have tried using the "pattern" option to put the telnet password in.  but can't get it to work

All I won't to be able to do is automatically run a few commands on other switches from the core.

Any ideas

Everyone's tags (1)
5 REPLIES
Cisco Employee

I can assure you EEM on IOS

I can assure you EEM on IOS can initiate telnet session without a hitch, but on IOX, still struggling to find out the workaroud.

 

proc remote_cmd_telnet { remote_host username password prompt_expect clist } {
    # this function will carry out each command contained in the clist on remote host.
    if { [catch {cli_open} result] } {
             PUTS $result
             return 1
        } else {
             array set cliarr $result
        }
    
    #Login to remote router
    
    if { [catch {cli_write $cliarr(fd) "telnet  $remote_host" } result] } {
         PUTS $result
         return 1
    }   

    PUTS $result

#   if { [catch {cli_read_pattern $cliarr(fd) "Username:"} result] } {
#        PUTS error "Failed to read response: '$result'"
#       return 1    
#     }
#   
#
#   PUTS $result
#
    if { [catch {cli_write $cliarr(fd) $username } result] } {
         PUTS $result
         return 1
        }

    PUTS $result

    if { [catch {cli_read_pattern $cliarr(fd) "Password:"} result] } {
        PUTS error "Failed to read response: '$result'"
        return 1    
     }   

    PUTS $result

    if { [catch {cli_write $cliarr(fd) $password } result] } {
         PUTS $result
         return 1
        }

    PUTS $result

    if { [catch {cli_read_pattern $cliarr(fd) "#"} result] } {

 

New Member

 Hi  xinchengYes EEM does

 

Hi  xincheng

Yes EEM does initiate telnet, I can see that from the debug but doesn't seem to accept the password using pattern.  What you have written looks great but way over my head.  I take it it I could just paste it to the switch and that would create the process remote_cms_telnet.

there is no username required, there is just the vty/telnet password.

All I want to do is run a progam that will telnet to various switches and run a few commands on a selection of ports It was 6 commands using EEM but it doesn't work.

Regards

 

Paul

 

 

Cisco Employee

Hi Paul,Please tell me which

Hi Paul,

Please tell me which IOS /IOX version you are running ?

New Member

Version 12.2(17r)SX3, RELEASE

Version 12.2(17r)SX3, RELEASE SOFTWARE (fc1)

Cisco Employee

Paul,I believe that IOS is

Paul,

I believe that IOS is not capable of doing that, like Ivan posted long time ago.

http://blog.ipspace.net/2007/10/you-cannot-start-telnet-session-from.html

If possible, please upgrade to 15.X, which fixed some bugs about eem.

 

278
Views
0
Helpful
5
Replies
CreatePlease login to create content