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

TCL within CiscoWorks

Mehdi Talei
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

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

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

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

Thank a lot Joseph for your excellent hint. On a single line works perfectly.