11-13-2007 02:19 PM - edited 03-03-2019 07:32 PM
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
Solved! Go to Solution.
11-13-2007 04:58 PM
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
11-13-2007 05:09 PM
tclsh
foreach address {
112.10.102.1
112.10.103.1
} {puts [exec ping $address]}
11-13-2007 04:58 PM
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
11-14-2007 12:36 PM
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
11-13-2007 05:09 PM
tclsh
foreach address {
112.10.102.1
112.10.103.1
} {puts [exec ping $address]}
11-14-2007 12:05 AM
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
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