08-11-2017 01:38 PM
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"
}
Solved! Go to Solution.
08-12-2017 12:09 PM
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"
08-12-2017 12:09 PM
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"
08-13-2017 01:07 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide