0

Could anyone tell me why this tcl command isn't being recognized by this version of Nexus?

someswitch-tcl# for { set i 1 } { $i < 10 } { incr i } { cli "ping vrf XYZ 10.xx.xx.$i" }
                      ^
% Invalid command at '^' marker.

It may not be displayed correctly here, but in the terminal the marker is shown just below the letter s in "set".

I tried to follow the guide from this blog, where it's suggested that such a set of commands should work on a Nexus device.

Any ideas?

1
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
    – Ron Maupin
    Dec 17 '20 at 14:41
5

Any ideas?

Yes. Looks like your ping syntax is wrong. To verify, exit the TCL shell and trying running the same ping command from your script substituting in an appropriate value: ping vrf XYZ 10.xx.xx.1

You will likely receive the exact same error message. Rather your command should look more like: ping 10.xx.xx.1 vrf XYZ.

You can also try something like the following in the TCL shell to validate the rest of your command is working as expected: for { set i 1 } { $i < 10 } { incr i } { puts $i }

When troubleshooting, you can often easily isolate the problem by simplifying what you are working with and testing the components separately to see what fails.

3

This is the script template I made and use to do a ping sweep followed by showing the ARP table for results. You can modify this to meet you needs.

----- BEGIN NX-OS TCL SCRIPT ------
tclsh
for {set i 1} {$i <= 254} {incr i} {
set var 10.0.0.
append var $i
exec "ping $var count 1 timeout 0"}
tclquit
sh ip arp | in 10.0.0.
----- END NX-OS TCL SCRIPT ------

In case you'd also like the IOS variant of my script, here you go.

------ BEGIN IOS TCL SCRIPT ------
tclsh
for {set i 1} {$i <= 254} {incr i} {
set var 10.0.0.
append var $i
exec "ping $var repeat 1 timeout 0"}
tclquit
sh ip arp | in 10.0.0.
----- END IOS TCL SCRIPT ------

Notice that it's almost identical. The only difference is the word "repeat" instead of "count" because that's the only difference in syntax Cisco made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.