cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
676
Views
0
Helpful
4
Replies

TCL scripts

Kevin Dorrell
Level 10
Level 10

I'm having a problem with TCL script. Normally I use IOS 12.2(15)T17, and I use a TCL script in the lab to test connectivity. THe script looks something like this (cut down):

tclsh

foreach address {

112.10.102.1

112.10.103.1

} {

ping $address

}

I'm using a box with IOS 12.4(2) now, and my TCL script doesn't seem to work any more. That is, it does the ping, but the output of the command does not appear on the console. Is there something I missed somewhere to make the output from the IOS commands appear on the console, like a "term mon" or something?

Kevin Dorrell

Luxembourg

2 Accepted Solutions

Accepted Solutions

scottmac
Level 10
Level 10

My reference stuff is at work, but shouldn't it be "exec ping $address;" ?

and the "foreach might be square brackets instead of the braces.

Here's an example from Cisco's main site:

foreach line [split [read $my_handle] "\n"] {

set new_line {#}

append new_line $line

puts $my_new_handle $new_line

}

Here's an online command guide:

http://www.cisco.com/en/US/products/sw/iosswrel/ps5207/products_feature_guide09186a00801a75a7.html

Good to see you back! I hope things have been well with you.

Good Luck

SCott

View solution in original post

Edison Ortiz
Hall of Fame
Hall of Fame

tclsh

foreach address {

112.10.102.1

112.10.103.1

} {puts [exec ping $address]}

View solution in original post

4 Replies 4

scottmac
Level 10
Level 10

My reference stuff is at work, but shouldn't it be "exec ping $address;" ?

and the "foreach might be square brackets instead of the braces.

Here's an example from Cisco's main site:

foreach line [split [read $my_handle] "\n"] {

set new_line {#}

append new_line $line

puts $my_new_handle $new_line

}

Here's an online command guide:

http://www.cisco.com/en/US/products/sw/iosswrel/ps5207/products_feature_guide09186a00801a75a7.html

Good to see you back! I hope things have been well with you.

Good Luck

SCott

Thanks for that, both of you. Yes it needs to be puts [exec ping $address]. That is a change of behavior from 12.2T to 12.4, and shows why I should be training with the latest IOS and not with ancient history.

Thanks for the welcome Scott. Yes, I am back - purely for selfish reasons. I hope that participating in NetPro can repair the damage to my self-esteem following my recent failure in the CCIE lab exam. (As well as ramping up my technical skills for the next attempt.)

It's nice to see some old names again, but sad to see that some have disappeared in the intervening year or so.

Kevin Dorrell

Luxembourg

Edison Ortiz
Hall of Fame
Hall of Fame

tclsh

foreach address {

112.10.102.1

112.10.103.1

} {puts [exec ping $address]}

OK Edison and Scott, thanks both of you. I'll give it a try when I get home this evening.

It is a strange difference in behavior. Under 12.2T it worked without the exec, but clearly something has changed. I know it is actually doing the ping 'cos I can see it in the debug ip icmp in the router I am pinging. And a puts "Hello world" works OK. It's just the output of the ping that isn't displayed.

I'll give it a go this evening and let you know the result.

Kevin Dorrell

Luxembourg

Review Cisco Networking for a $25 gift card