cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Cisco announces new innovations in SD-WAN, ISRs, SD-WAN Services, and Catalyst 9000 Series switches


157
Views
0
Helpful
5
Replies
Beginner

Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

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,

5 REPLIES
Highlighted
VIP Advisor

Re: Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

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

 


Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question
Beginner

Re: Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

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,

VIP Advisor

Re: Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

As I said previously, you can create a text file with the tcl extension and upload it into your device.
If you want to create it locally using tclsh command line, you would need to put the code into the following:

puts [open "flash:traceroute.tcl: w+] {
code-sent-previously
}

Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question
Beginner

Re: Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

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?

VIP Advisor

Re: Traceroute TCL Script on Cisco c4500 [Cisco IOS XE]

Yes i used it but not on latest devices. Since Cisco provides a guest shell (Linux CentOS container) on IOS-XE, i only use this machine with Python scripts for this kind of scripts.

I don't have any 4500 right now to test this tcl. Give me few days to test it in another device and I'll come back with some results.

Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question
CreatePlease to create content
Content for Community-Ad

Blog-Cisco Community Designated VIP Class of 2019