TCL function (regexp and regsub function only don partial)

  • 0
  • 1
  • Problem
  • Updated 1 year ago
  • Solved

XOS 15.5.2.9 patch1-5

set var a "12345:54321:7806"

set var x $TCL(regexp -all {([0-9]*):([1-5]{5}):([0-9]{1,4})} $a match s1 s2 s3)

show var

----------------------------------------
Count : 5
----------------------------------------

------------------------------------------------------------------
variableName                      variableValue
--------------------------------  --------------------------------
a                                 12345:54321:7806
CLI.SESSION_TYPE                  telnet
CLI.USER                          admin
STATUS                            0
x                                 1

Form display i can't get match, s1, s2 and s3 variable

Is this a bug

set var y $TCL(regexp -all {:} $a / s4)

30B-01.10 # show var
----------------------------------------
Count : 6
----------------------------------------

------------------------------------------------------------------
variableName                      variableValue
--------------------------------  --------------------------------
a                                 12345:54321:7806
CLI.SESSION_TYPE                  telnet
CLI.USER                          admin
STATUS                            0
x                                 1
y                                 2
------------------------------------------------------------------

Form above show var result why i can get match variable content

is this another bug

if that are bugs please quickly correct ...........









Photo of Helpme

Helpme

  • 260 Points 250 badge 2x thumb

Posted 4 years ago

  • 0
  • 1
Photo of Paul Russo

Paul Russo, Alum

  • 9,694 Points 5k badge 2x thumb
Hello Helpme

Can I ask what your end goal is?  I don't see where variables S1 S2 S3 are defined.

Thanks
P
Photo of Helpme

Helpme

  • 260 Points 250 badge 2x thumb

From original document that's variable will auto generate, i already test if give that variable initialize but that regexp function will exist same bug....


ena cli scrip
set var a "12345:54321:98765"
set var s1 0
set var s2 0
set var s3 0
set var s0 0
set var x $TCL(regexp -all -- {([\d]{1,5}):([\d]*):([\d]{5})} $a s0 s1 s2 s3)

 sh var
----------------------------------------
Count : 9
----------------------------------------

------------------------------------------------------------------
variableName                      variableValue
--------------------------------  --------------------------------
a                                 12345:54321:98765
CLI.SESSION_TYPE                  telnet
CLI.USER                          admin
s0                                0
s1                                0
s2                                0
s3                                0
STATUS                            0
x                                 1
------------------------------------------------------------------

The regsub function always only do the match function but variable will not assign ...

so i think that is a bug.

I use ActiveTCL test that above two command the match variable function will ok.




Photo of Paul Russo

Paul Russo, Alum

  • 9,694 Points 5k badge 2x thumb
Hey Helpme
Thanks for the update. I will check it out but if you think this is a bug then please open up a case with GTAC as that is the only way to get bugs fixed.

Thanks
P
Photo of Ed McGuigan

Ed McGuigan

  • 500 Points 500 badge 2x thumb
I was trying this out on what is my current version of firmware 15.6.3.1 and it is definitely true that all you can do with regexp is determine if a string matches a pattern. There are no match variable assignments and regsub will do nothing useful.

This is very disappointing because to work around this, an awful lot of extra and quite complex coding is needed. I am going to load up a recent version of XOS and see if anything has changed.
Photo of Grosjean, Stephane

Grosjean, Stephane, Employee

  • 13,676 Points 10k badge 2x thumb
What about using Python instead of CLI scripting?