[OpenSIPS-Users] string comparison
volga629
volga629 at networklab.ca
Thu Apr 23 15:26:22 EST 2020
Hello John,
Thank you for reply.
I wonder if it something to do that variable contain numbers and letters.
Example: tls_201
I wonder if I can compare md5 .
volga629
On 4/23/20 11:26 AM, John Quick wrote:
> Hi Volga,
>
> I just added a check on one of my test servers, making use of some existing code that sets a variable $var(srctype) to various values including:
>
> if (is_registered("location"))
> $var(srctype) = "regd-user";
>
> The new code I added just below looks like this:
>
> $var(teststr) = "regd-user";
> if ($var(srctype) == $var(teststr))
> xlog("L_WARN", "## SOURCE IS A REGISTERED USER ##\n");
>
> Then I registered an IP Phone and made a call. Output to my log file:
> 2020-04-23 15:10:40 ## SOURCE IS A REGISTERED USER ##
>
> So the basic test for comparing strings should work. There must be some other explanation.
> I have known situations where it was necessary to cast a string value to be recognised as an integer, but you are only testing strings.
> Could there be a leading or trailing space? Perhaps you need to use a trim function. Check out the string transformations:
> https://www.opensips.org/Documentation/Script-Tran-2-4#toc1
> To understand what is happening you could try using regex test, =~ instead of equality, ==
> You could report the length of the string values stored in the two vars, using {s.len} transformation (see above link).
>
> John Quick
> Smartvox Limited
>
>
> -----Original Message-----
> From: volga629 <volga629 at networklab.ca>
> Sent: 23 April 2020 14:43
> To: john.quick at smartvox.co.uk; users at lists.opensips.org
> Subject: Re: [OpenSIPS-Users] string comparison
>
> Hello John,
>
> I tested var to var
>
> and test still failing
>
> Tried
>
> if($var(tls-frompbx)=="$var(usr_check_tls)")
>
> or this
>
> if($var(tls-frompbx)==$var(usr_check_tls))
>
> volga629
>
>
> On 4/23/20 9:41 AM, John Quick wrote:
>> Hi Volga
>>
>> Please could you always format your emails to the users group as plain
>> text, not HTML.
>> I had to copy and paste then save and re-open just to read your question.
>>
>> I would think the most likely explanation for the string comparison
>> failing is that you are comparing an $avp with a $var They are
>> different - in particular, an AVP can hold several values, somewhat
>> like an array type in other languages.
>> Can you try the same test but with a var for both sides of the comparison.
>>
>> John Quick
>> Smartvox Limited
>>
>>
>>
>
More information about the Users
mailing list