cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2664
Views
0
Helpful
8
Replies
Highlighted
Beginner

supressing output in a TcL script on NX-OS

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.

Everyone's tags (1)
8 REPLIES 8
Highlighted
Hall of Fame Cisco Employee

supressing output in a TcL script on NX-OS

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 ""

Highlighted
Beginner

supressing output in a TcL script on NX-OS

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.

Highlighted
Beginner

supressing output in a TcL script on NX-OS

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.

Highlighted
Hall of Fame Cisco Employee

supressing output in a TcL script on NX-OS

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.

Highlighted
Beginner

It's been a long time on this

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.

Highlighted
Cisco Employee

there is a way to do this.

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#

Highlighted
Beginner

Re: there is a way to do this.

"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

 

Highlighted

Re: there is a way to do this.

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.

CreatePlease to create content
Content for Community-Ad