[OpenSIPS-Users] Reading contents of a file - OpenSIPS 3.1
Maxim Sobolev
sobomax at sippysoft.com
Fri Nov 13 14:54:07 EST 2020
Use app_python? Parsing is trivial and you can call internal function
i.e. cache_store()
right from your Python code.
-Max
On Fri., Nov. 13, 2020, 6:50 a.m. Mark Allen, <mark at allenclan.co.uk> wrote:
> Just would like to consult the hive mind. I want to read the contents of a
> multi-line text file to be used by my OpenSIPS config. Ideally, I'll get a
> key:value CSV pair from the file and store each pair in memcache - e.g.
>
> file contains:
>
> a, 113
> b, 214
> c, 771
>
> read it in line by line and cache_store() with the letter as the attribute
> and the number as the value.
>
> I was thinking that I could use exec() to 'cat' the contents of the file,
> storing stdout in an AVP, and then work through that array splitting letter
> and number with a string transformation ready for cache_store(). However,
> if I do this the full file contents are stored as a single string in the
> first value with "#012" added in place of the new lines.
>
> Obviously, I can use a string transform s.select{} using #012 as a
> delimiter in an intermediary step, but am I just doing this the hard way?
> Is there a better way to achieve this?
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20201113/68ffa1fa/attachment-0001.html>
More information about the Users
mailing list