TCL scripts

Answered Question
Nov 13th, 2007

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

I have this problem too.
0 votes
Correct Answer by Edison Ortiz about 9 years 3 weeks ago

tclsh

foreach address {

112.10.102.1

112.10.103.1

} {puts [exec ping $address]}

Correct Answer by scottmac about 9 years 3 weeks ago

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

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
Correct Answer
scottmac Tue, 11/13/2007 - 16:58

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

Kevin Dorrell Wed, 11/14/2007 - 12:36

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

Correct Answer
Edison Ortiz Tue, 11/13/2007 - 17:09

tclsh

foreach address {

112.10.102.1

112.10.103.1

} {puts [exec ping $address]}

Kevin Dorrell Wed, 11/14/2007 - 00:05

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

Actions

This Discussion