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

Long ios_config Commands

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"
}

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

I don't recommend using tclsh

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"

2 REPLIES
Cisco Employee

I don't recommend using tclsh

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"

Community Member

This certainly helps. In this

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.

577
Views
0
Helpful
2
Replies
CreatePlease to create content