12-06-2010 01:09 PM
Hello all,
I have written the following script which shuts down the "down" interfaces on Catalyst 2960. When I copy and paste the script via SSH, it works fine without any error message, but when I execute it via CiscoWorks (RME 4.3.1) the job fails with the following error message:
tclsh
Switch(tcl)#
for {set x 0} {$x<24} {incr x} {
missing close-brace
Switch(tcl)#
set etat [string range [lrange [exec sh ip int brief | i FastEthernet0/$x] 4 4] 0 4 ]
can't read "x": no such variable
Switch(tcl)#
if { [string equal $etat "down"] } {
missing close-brace
Switch(tcl)#
puts [ios_config "Interface FastEthernet0/$x" "shut"]
can't read "x": no such variable
Switch(tcl)#
}
invalid command name "}"
}
^
% Invalid input detected at '^' marker.
Switch(tcl)#
}
invalid command name "}"
}
^
% Invalid input detected at '^' marker.
I am wondering why I get "missing close-brace" error message!
Any help is appreciated.
Mehdi
Solved! Go to Solution.
12-07-2010 01:39 AM
When you type in the script line-by-line like this, you get intermediate prompts requesting additional block data. LMS cannot programmatically handle those prompts. Instead, try converting your script to a single line:
for {set x 0} {$x<24} {incr x} { set etat [string range [lrange [exec sh ip int brief | i FastEthernet0/$x] 4 4] 0 4 ] ; if { [string equal $etat "down"] } { puts [ios_config "Interface FastEthernet0/$x" "shut"] } }
12-07-2010 01:39 AM
When you type in the script line-by-line like this, you get intermediate prompts requesting additional block data. LMS cannot programmatically handle those prompts. Instead, try converting your script to a single line:
for {set x 0} {$x<24} {incr x} { set etat [string range [lrange [exec sh ip int brief | i FastEthernet0/$x] 4 4] 0 4 ] ; if { [string equal $etat "down"] } { puts [ios_config "Interface FastEthernet0/$x" "shut"] } }
12-07-2010 04:41 AM
Thank a lot Joseph for your excellent hint. On a single line works perfectly.
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