01-03-2019 12:52 PM
Hello,
I was wondering, how to create, save, and run a TCL script on Cisco c4500 [Cisco IOS XE] performing a traceroute and saving the output to txt file.
Thanks,
01-03-2019 06:12 PM - edited 01-03-2019 06:13 PM
Hi
Sorry if there're some mispelling error.
Just wrote something quick over ipad.
Can you test this script?
set fileoutput [open "flash:tracerouteresult.txt" w]
foreach address {8.8.8.8 1.1.1.1} {
set output [exec "traceroute $address source g0/0"]
puts $fileoutput $output
}
close $fileoutput
Replace g0/0 by your source interface from where the traceroute should be initiated.
Put this script into a tcl file called traceroute.tcl (example of name, you can call it whatever you want), then put this file into the flash and from the device you can run it using the command:
tclsh flash:traceroute.tcl
01-04-2019 02:47 PM
Thank you Francesco.
I tried to apply this script, but there still seems some adjustments necessary:
RTR(tcl)#set fileoutput [open "bootflash:tracerouteresult.txt" w]
file21
RTR(tcl)#foreach address {
+>8.8.8.8
+>1.1.1.1} {set output [exec "traceroute $address source vlan 125"]
+>puts $fileoutput $output
+>}
^
% Invalid input detected at '^' marker.
Could you please take a look.
Thanks,
01-04-2019 09:00 PM
01-06-2019 02:42 PM
Thank you for providing me with this info.
However, there seems to bit more into it including a bug when executing the traceroute command in certain IOS XE versions; see link below for more details:
https://community.cisco.com/t5/network-management/tcl-and-traceroute/td-p/1778334
Have you ever tried your posted suggestions?
01-06-2019 08:45 PM
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: