cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
591
Views
0
Helpful
2
Replies

LUA logical and match

Paul Freiberg
Level 1
Level 1

Hi all,

I have that diversion string:

Diversion: " XXX" < sip:+4945131012091@172.22.1.101> ;reason=no-answer;privacy=off;screen=yes
Diversion: " XXX" < sip:+4945131012092@172.22.1.101> ;reason=deflection;privacy=off;screen=yes

Now I want to match on "+4945131012092" and "deflection":

if (string.match(diversion, "+4945131012092") and string.match(diversion, "deflection")) then

But it does not work, if I just match on on "+4945131012092" it works and if I just match on "deflection" it works too.

If I try to match on "+4945131012092@172.22.1.101> ;reason=deflection" it does not work too.

If I test it in Lua-5.1.5, it works.

Can anybody help me?

2 Replies 2

Nadeem Ahmed
Cisco Employee
Cisco Employee

can you please provide me your lua script and what is the CUCm version you are try to implement this?

Br,
Nadeem

Br, Nadeem Please rate all useful post.

I had a logical mistake in my scipt with:

if (string.match(diversion, "+4945131012092") and string.match(diversion, "deflection")) then

I had to change it to:

elseif string.match(diversion, "+4945131012092",string.find(diversion, ",")) and string.match(diversion, "deflection",string.find(diversion, ",")) then

because I had the same syntax with -2091 before in the script.

After I debugged the script and found out that the sting is not a multiline string, it is separated by ",", I am matching just after the "," with combination of math and find.

The debug output is:

//SIPLua/Script/trace_output: Diversion is "XXX" <sip:+4945131012091@172.22.1.101>;reason=no-answer;privacy=off;screen=yes,"XXX" <sip:+4945131012092@172.22.1.101>;reason=deflection;privacy=off;screen=yes

So I found out that the RTMT output was filled with spaces.

Next time I will immediately debug the strings.

Regards and thanks 4 reading,

Paul

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: