01-03-2014 01:57 PM
I am running a TcL script on a Nexus 7k and would like to suppress the output from cli commands. The TcL book says it can be done by enteringt "log_user 0", which works on a ASR router but not the Nexus switch.
Any suggestions would be appreciated.
01-03-2014 03:59 PM
Tcl on NX-OS is not the same as IOS. The log_user command does not work. As a workaround, make the last command something that doesn't display any output. For example:
cli "show version" ; puts ""
01-07-2014 12:37 PM
On a nexus 5500 running 5.1(3)N2(1b) -- using the workround of adding a blank command at the end doesn't work either.
I'm trying to find a solution as well. Doing a large number of show commands, using regex to trim the results to just what I want, and then display only the bits we're interested in, in the format we want. But preferrably without all the junk scrolling by as the script runs.
01-31-2014 12:03 PM
I'm also trying to do something similiar to sojouner9 just not as complicated.. I"m just trying to make a known IOS ping script, just as pretty on nx-os. It runs fine but I need to supress the pings results out from the script. Here is the script and the results.... Any help of course is appreciate.
puts ""
cli "show clock"
puts " -- Start pinging ..."
puts ""
foreach i {
10.205.10.1
10.228.10.1
} {
if {[regexp "64" [exec "ping $i cou 3" ]]} {puts "$i OK"} else {puts "$i ***unreachable***"}
puts ""
puts ""
}
cli "show clock"
puts "-- Pings stopped."
### Results when ran ####
switch#
tclsh bootflash:psr.tcl
15:00:42.566 EST Fri Jan 31 2014
-- Start pinging ...
PING 10.205.10.1 (10.205.10.1): 56 data bytes
64 bytes from 10.205.10.1: icmp_seq=0 ttl=248 time=33.955 ms
64 bytes from 10.205.10.1: icmp_seq=1 ttl=248 time=33.884 ms
64 bytes from 10.205.10.1: icmp_seq=2 ttl=248 time=33.828 ms
--- 10.205.10.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.00% packet loss
round-trip min/avg/max = 33.828/33.889/33.955 ms
10.205.10.1 OK
PING 10.228.10.1 (10.228.10.1): 56 data bytes
64 bytes from 10.228.10.1: icmp_seq=0 ttl=254 time=0.756 ms
64 bytes from 10.228.10.1: icmp_seq=1 ttl=254 time=0.602 ms
64 bytes from 10.228.10.1: icmp_seq=2 ttl=254 time=0.577 ms
--- 10.228.10.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.00% packet loss
round-trip min/avg/max = 0.577/0.645/0.756 ms
10.228.10.1 OK
15:00:42.918 EST Fri Jan 31 2014
-- Pings stopped.
02-02-2014 03:14 PM
It looks like a limitation (at least on N7K) of the exec and cli commands. Other "set" results can be suppressed using the puts trick. I couldn't find an existing enhancement request on this, so I suggest you contact your account team to raise one.
02-25-2015 07:47 AM
It's been a long time on this one. I wish it worked... seems like a no brainer to me. TCL is an old language; the ability to store output in a variable (thus not displaying it) for further processing through its string manipulation facilities is fundamental.
07-08-2016 04:57 AM
there is a way to do this. there is the 'clis' command which is a silent cli (no output to stdout). it works like this:
set data [clis "sh sys uptime"]
puts "data\n----\n$data"
nxos# tclsh test.tcl
data
----
System start time: Tue Jul 5 08:11:46 2016
System uptime: 3 days, 5 hours, 40 minutes, 57 seconds
Kernel uptime: 3 days, 5 hours, 42 minutes, 44 seconds
nxos#
04-02-2019 12:46 AM
"clis" seems to be without broad device-support...
should _this_ really be the way to go if you don't want do write script for every device-type?
* try the "clis"-command
* if not successful, fall back to "exec"-command which is supported in every device
if {[catch {set showversion [clis {show version}]} e] } { if {[catch {set showversion [exec {show version}]} e] } { puts "ERR: Show Version - $e" break } }
puts $showversion
04-18-2019 09:16 AM
Unfortunately this highlights the difference between an interactive TCL session and a scripted TCL session. When TCL shell is called with a script, local echo is suppressed. When TCL is invoked interactively, local echo is enabled. This is standard TCL behavior.
02-10-2021 05:45 AM
at NXOS there is local echo even within scripts
08-23-2022 06:00 AM
Good to know! Thanks
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