cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2054
Views
0
Helpful
2
Replies

Long ios_config Commands

kidseven112002
Level 1
Level 1

I am looking for a way to write a standby config script that has a lot of commands, but the line following the ios_config has a lot of commands that need to be set. Is there a way to chop it up so one line isn't that long? I tried many ios_config lines and new line (\n) to no avail. Here is the script I am trying to simplify. Please help. 


puts [open "nvram:test.tcl" w+] {

ios_config "config t"

set y 0
foreach vlan $argv {
    ios_config "vlan [lindex $argv $y]" "ip address 192.168.[lindex $argv $y].2 255.255.255.0" "standby [lindex $argv $y] ip 192.168.[lindex $argv $y].254" "standby [lindex $argv $y] priority 105" "standby [lindex $argv $y] preempt"
    incr y
}

ios_config "end"
}

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

I don't recommend using tclsh if you can help it.  Using EEM Tcl will give you much better control over command execution, and work better with AAA.

However, if you do need to use tclsh, you'll want to pull out the lines:

ios_config "config t"

And:

ios_config "end"

To solve the problem of length, just break up the command into multiple:

ios_config "int vlan [lindex $argv $y]" "ip address 192.168.[lindex $argv $y].2 255.255.255.0"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] ip 192.168.[lindex $argv $y].254"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] priority 105"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] preempt"

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

I don't recommend using tclsh if you can help it.  Using EEM Tcl will give you much better control over command execution, and work better with AAA.

However, if you do need to use tclsh, you'll want to pull out the lines:

ios_config "config t"

And:

ios_config "end"

To solve the problem of length, just break up the command into multiple:

ios_config "int vlan [lindex $argv $y]" "ip address 192.168.[lindex $argv $y].2 255.255.255.0"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] ip 192.168.[lindex $argv $y].254"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] priority 105"

ios_config "int vlan [lindex $argv $y]" "standby [lindex $argv $y] preempt"

This certainly helps. In this instance it wouldn't be the most useful to use TCL, but I'm just getting practice at applications. However, your assistance will help me in creating templates for new network devices.