[c-nsp] tcl basic question (Phil Mayers)
Mann, Jason
jamann at mt.gov
Tue Jul 1 16:37:55 EDT 2014
Could try trimming the output.
set COPP [ exec {show policy-map control-plane} ]
foreach map [ regexp -inline {Class-map:[^\n]+\s } $COPP ] {
}
if [ regexp -all {conformed (\d+) packets} $COPP map0] {
set tmp [string trim $map $map0]
puts $ tmp
}
------------------------------
Date: Thu, 26 Jun 2014 13:20:01 +0200
From: selamat pagi <ketimun at gmail.com>
To: cisco-nsp <cisco-nsp at puck.nether.net>
Subject: [c-nsp] tcl basic question
Message-ID:
<CAHkCuxqtckGJi3PRS9H+qf1k8GbmHf4sy0mJkceMdMYuyqfNSg at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Im very new to tcl scripts, therefore please apologies this question, I was not able to answer to myslef, even after googling for quite some time.
My script:
set COPP [ exec {show policy-map control-plane} ] foreach map [ regexp -inline {Class-map:[^\n]+\s } $COPP ] {
}
if [ regexp -all {conformed (\d+) packets} $COPP map0] {
puts -nonewline "$map $map0"
}
Gives output:
Class-map: SNMP (match-all)
conformed 38118 packets
Required output:
Class-map: SNMP (match-all) conformed 38118 packets --> on same line
I tried with option -nonewline or \n but somehow I did not get it right.
many thanks, keti
------------------------------
Message: 3
Date: Thu, 26 Jun 2014 12:49:28 +0100
From: Phil Mayers <p.mayers at imperial.ac.uk>
To: cisco-nsp at puck.nether.net
Subject: Re: [c-nsp] tcl basic question
Message-ID: <53AC08C8.2030907 at imperial.ac.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 26/06/14 12:20, selamat pagi wrote:
> Gives output:
> Class-map: SNMP (match-all)
> conformed 38118 packets
$map probably contains the terminating newline. You need to strip it. No idea how in TCL.
More information about the cisco-nsp
mailing list