cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2577
Views
0
Helpful
3
Replies

regexp problem with TCL Script

Hello,

I'm having some troubles with my regexp in a tcl script.

My switch 3750 doesn't want to compil my script if there is [0-9] or \d in my script ...

After a show energywise children I'm doing:

set intd [ regexp -all -line -inline "1\/0\/." $result ]

($result is the show energywise cli result)

It work with interfaces from 1/0/1to9.

set intd [ regexp -all -line -inline "1\/0\/.." $result ]

It work with interfaces from 1/0/10to48

but i need to have all interfaces in the same regexp, why "1\/0\/[0-9]+" or "1\/0\/\d+" don't work ?

Here is my ios : c3750-ipservicesk9-mz.122-53.SE1.bin

Anybody have a clue ?

Thanks

1 Accepted Solution

Accepted Solutions

Replace the "" with {}.  That is, you need to escape the '[' if you want to use it, or include it in literal "{}".  For example:

set intd [ regexp -all -line -inline {1\/0\/[0-9]+.} $result ]

View solution in original post

3 Replies 3

Maybe need more details, my eem version is :

Embedded Event Manager Version 3.20                                           
Component Versions:                                                           
eem: (v320_throttle)2.1.50                                                    
eem-gold: (v320_throttle)1.0.4                                                
eem-call-home: (v320_throttle)1.0.4                                           
Event Detectors:                                                              
Name                Version   Node        Type                                
application         01.00     node0/0     RP                                  
mat                 01.00     node0/0     RP                                  
neighbor-discovery  01.00     node0/0     RP                                  
identity            01.00     node0/0     RP                                  
syslog              01.00     node0/0     RP                                  
routing             03.00     node0/0     RP                                  
cli                 01.00     node0/0     RP                                  
counter             01.00     node0/0     RP
interface           01.00     node0/0     RP
ioswdsysmon         01.00     node0/0     RP
none                01.00     node0/0     RP
oir                 01.00     node0/0     RP
snmp                01.00     node0/0     RP
snmp-object         01.00     node0/0     RP
ipsla               01.00     node0/0     RP
snmp-notification   01.00     node0/0     RP
timer               01.00     node0/0     RP
rpc                 01.00     node0/0     RP

My problem is here :

if [catch {cli_exec $cli(fd) "show ene chi | include SEP"} result] {
    error $result $errorInfo
}
    puts "$result"

foreach intf [ regexp -all -line -inline "00.{10}" $result ] {   /* this line is good, it save the mac address of an equipment*/
  set intd [ regexp -all -line -inline "1\/0\/.." $result ]
  puts "Mac-address:$intf"
  puts "test:$intd"
  }

So my code works but the regexp "1\/0\/.." give me the interface from 1/0/1 to 9 betwin { }.

If i try "1\/0\/[0-9]+" or "1\/0\/\d+", it returns nothing, and I have an error at compilation.

Replace the "" with {}.  That is, you need to escape the '[' if you want to use it, or include it in literal "{}".  For example:

set intd [ regexp -all -line -inline {1\/0\/[0-9]+.} $result ]

Thank you, my problem is solved. I didn't know for the { }, it's perfect.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: