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 <[email protected]>
To: cisco-nsp <[email protected]>
Subject: [c-nsp] tcl basic question
Message-ID:
        <cahkcuxqtckgji3prs9h+qf1k8gbmhf4sy0mjkcemdmyuyqf...@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 <[email protected]>
To: [email protected]
Subject: Re: [c-nsp] tcl basic question
Message-ID: <[email protected]>
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.




_______________________________________________
cisco-nsp mailing list  [email protected]
https://puck.nether.net/mailman/listinfo/cisco-nsp
archive at http://puck.nether.net/pipermail/cisco-nsp/

Reply via email to