cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2578
Views
0
Helpful
3
Replies

script tcl for sync settings router HSRP

r-barbosa
Level 1
Level 1

Hi all,

I development the script tcl for syncronize the settings two router in mode hsrp. Follow bellow

proc gerar_configuracoes {

  set confs_nat [ exec "show running-config | include nat" ]

  set confs_acl [ exec "show running-config | include access-list" ]

  set confs_hsrp_outside [ exec "show running-config interface fastEthernet 0/0 | inc standby" ]

  set confs_hsrp_inside [ exec "show running-config interface fastEthernet 0/1 | inc standby" ]

  set acl_confs "access-lists_confs.txt"

  set nat_confs "nat_confs.txt"

  set hsrp_confs "hsrp_confs.txt"

  set FileAclId [open $acl_confs "w"]

  set FileNatId [open $nat_confs "w"]

  set FileHsrpId [open $hsrp_confs "w"]

  puts $FileAclId $confs_acl

  puts $FileNatId $confs_nat

  puts $FileHsrpId $confs_nat

  close $FileAclId

  close $FileNatId

  close $FileHsrpId

}

My idea is generate file with commands, with this script the file with commands is generate. Now how go sync the settings?

I thought of using rcmd rsh but with running the command "rsh 192.168.0.3 /user command" does not allow me to run the command "configure terminal" then run the commands themselves. any ideas

Regards.

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

To do configurtation in tclsh, use "ios_config".  For example:

ios_config "int fa0/0" "shut" "end"

View solution in original post

The ios_config command is a Tcl function, not an IOS command.  So, you need to wrap it within a Tcl script.  For example, assume you have a Tcl script like (call it config.tcl):

ios_config "int fa0/0" "shut" "end"

Then your rsh command would be:

rsh 192.168.0.3 /user cisco tclsh config.tcl

View solution in original post

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

To do configurtation in tclsh, use "ios_config".  For example:

ios_config "int fa0/0" "shut" "end"

Hi,

I trying the command.

R1#rsh 192.168.0.3 /user cisco ios_config "int fa0/0" "shut" "end"

Line has invalid autocommand "ios_config "int fa0/0" "shut" "end""

R1#

the command worked

R1#rsh 192.168.0.3 /user cisco show arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  192.168.1.1            41   0000.0c07.ac01  ARPA   FastEthernet0/1

Internet  192.168.0.2            58   ca00.0ef8.0008  ARPA   FastEthernet0/0

Internet  192.168.1.3             -   ca02.0ef8.0006  ARPA   FastEthernet0/1

Internet  192.168.1.2            31   ca00.0ef8.0006  ARPA   FastEthernet0/1

Internet  192.168.0.3             -   ca02.0ef8.0008  ARPA   FastEthernet0/0

Internet  192.168.1.20            -   ca02.0ef8.0006  ARPA   FastEthernet0/1

R1#

Any idea

The ios_config command is a Tcl function, not an IOS command.  So, you need to wrap it within a Tcl script.  For example, assume you have a Tcl script like (call it config.tcl):

ios_config "int fa0/0" "shut" "end"

Then your rsh command would be:

rsh 192.168.0.3 /user cisco tclsh config.tcl