Hello,
As per Kamailio documentation, $RANDOM returns a random value from the [0 - 2^31) range. But when testing it it's always returning a random number of 9 or 10 digits. I'm not sure if it's always the case or if it can also returns numbers with 1 or 2 digits as well.
Another question, how can I force it to return a number of specific digits starting with certain prefix.
Regards,
Hi,
If you want 5 random digits stored in $var(seq), try this:
$var(seq) = ''; $var(i) = 5;
while($var(i) > 0) { $var(seq) = $var(seq) + ($RANDOM mod 10); $var(i) = $var(i) - 1; }
My results, test logging xinfo("SEQUENCE = $var(seq)\n"):
2(18) INFO: [e82447e7-9768-123c-3c9b-c276a1266a9e:R-HANDLE_INBOUND_INVITE] SEQUENCE = 61862 7(23) INFO: [e91e3cf2-9768-123c-3c9b-c276a1266a9e:R-HANDLE_INBOUND_INVITE] SEQUENCE = 70553 9(25) INFO: [e9564964-9768-123c-3c9b-c276a1266a9e:R-HANDLE_INBOUND_INVITE] SEQUENCE = 43908 3(19) INFO: [e846d9cd-9768-123c-3c9b-c276a1266a9e:R-HANDLE_INBOUND_INVITE] SEQUENCE = 80086
-- Alex
On Jul 7, 2023, at 8:21 AM, Ali Taher ataher@vanrise.com wrote:
Hello, As per Kamailio documentation, $RANDOM returns a random value from the [0 - 2^31) range. But when testing it it’s always returning a random number of 9 or 10 digits. I’m not sure if it’s always the case or if it can also returns numbers with 1 or 2 digits as well. Another question, how can I force it to return a number of specific digits starting with certain prefix. Regards, __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: