<div dir="auto"><div><a href="http://www.kamailio.org/wiki/cookbooks/5.5.x/core#arithmetic_operations">http://www.kamailio.org/wiki/cookbooks/5.5.x/core#arithmetic_operations</a><div dir="auto"><br></div><div dir="auto">$RANDOM mod 100</div><div dir="auto"><br></div><div dir="auto">Should give you random ints between 0 and 99.</div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 4, 2022, 03:41 Joel Serrano <<a href="mailto:joel@textplus.com">joel@textplus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I did, but I don't see how to limit the range:<div><br></div><div>From the docs: Returns a random value from the [0 - 2^31) range.</div><div><br></div><div>Is there a way to limit the range from 1-100 for example? Or maybe the way is to use $RANDOM and just rely on the first/last 2 digits (essentially a 00-99 range)? </div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 3, 2022 at 10:40 AM Henning Westerholt <<a href="mailto:hw@gilawa.com" target="_blank" rel="noreferrer">hw@gilawa.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="DE">
<div>
<p class="MsoNormal"><span>Hello,<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">what about just using this PV:
<a href="https://kamailio.org/docs/modules/5.5.x/modules/cfgutils.html#idm438" target="_blank" rel="noreferrer">https://kamailio.org/docs/modules/5.5.x/modules/cfgutils.html#idm438</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">-- <u></u>
<u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning Westerholt –
</span><span><a href="https://skalatan.de/blog/" target="_blank" rel="noreferrer"><span lang="EN-GB" style="color:rgb(5,99,193)">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kamailio services –
</span><span><a href="https://gilawa.com/" target="_blank" rel="noreferrer"><span lang="EN-GB" style="color:rgb(5,99,193)">https://gilawa.com</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org" target="_blank" rel="noreferrer">sr-users-bounces@lists.kamailio.org</a>>
<b>On Behalf Of </b>Joel Serrano<br>
<b>Sent:</b> Tuesday, May 3, 2022 6:20 PM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.kamailio.org" target="_blank" rel="noreferrer">sr-users@lists.kamailio.org</a>><br>
<b>Subject:</b> [SR-Users] Tips on picking random element from a list<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Hi Everyone, <u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">I have to implement a flow where outbound calls get their caller-id set with a random number from a pool.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">I've been looking around and, as most of the time, there are tons of ways to implement something like this... This is a simple implementation, the number pool is fixed and will not change (so I could have it hard-coded
 in the config if required).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">My initial approach was:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">1- Try to keep it simple, with no dependencies, and all done in the config script.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">2- If #1 is "ugly", then I'd probably go with some inline code using python/lua/etc<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">3- If #2 is "ugly", then I'd go with having the info in a DB and just run a query<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">I think #2 and #3 might be overkill for something so "simple" but I haven't had to work too much with randomness in Kamailio, so any tips/suggestions on where to store the number list and how to pick one randomly
 would be awesome!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Thanks!!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Joel.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>

</blockquote></div>
__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank" rel="noreferrer">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div></div></div>