If the value is already quoted, then #!devenv should be used, that's the reason there are two variants to take it as it is or surround with quotes.
Cheers, Daniel On 09.12.21 17:50, Ben Kaufman wrote: > > It does appear that #!devenvs subsequently has problems if the > environmental variable is already quoted, though. I’ll put together > an example and open a ticket for it. > > > > > > *From:* Ben Kaufman > *Sent:* Thursday, December 9, 2021 8:57 AM > *To:* Kamailio (SER) - Users Mailing List <[email protected]> > *Subject:* RE: [SR-Users] Unquoted values from #!defenv > > > > Thank you. It’s tested and working with this simple config: > > > > > > #!KAMAILIO > > loadmodule "xlog" > loadmodule "pv" > loadmodule "evrexec" > > modparam("evrexec", "exec", "name=evrexec:timer;wait=1000;workers=1;") > > #!defenv HOME > > request_route{ > forward(); > } > > event_route[evrexec:timer] { > xlog("L_N", "HOME: " + HOME + "\n"); > } > > > > > > Regards, > > > Kaufman > > > > > > *From:* Daniel-Constantin Mierla <[email protected]> > *Sent:* Thursday, December 9, 2021 3:55 AM > *To:* Kamailio (SER) - Users Mailing List > <[email protected]>; Ben Kaufman <[email protected]> > *Subject:* Re: [SR-Users] Unquoted values from #!defenv > > > > I pushed the code to enclose the value in between quotes. Can you test > and see if works now? > > Cheers, > Daniel > > On 08.12.21 19:07, Daniel-Constantin Mierla wrote: > > I expected the quoted mode parameter does the work -- I will check > and push the update. > > Regarding support for undefined env values, maybe add something > like #!trydefenv, because I find #!defenv useful at is it, to be > used when the env variable must be set for proper working of > kamailio (e.g., DB url) and fail to start if not set. > > Cheers, > Daniel > > On 08.12.21 17:17, Ben Kaufman wrote: > > Daniel, > > > > Is the #!defenvs feature still a work in progress? I wrote a > change to add #!defenvn and #!defenvns to allow for undefined > environmental variables, and noticed that the string quoting > on #!defenvs doesn’t do anything except log the quoting mode > in /src/core/ pp_define_set(). > > *Ben Kaufman* > > /Sr. VoIP Engineer/ > > > P: > > E: [email protected] > > 24 hour client support: 855.639.6300 <tel:+18556396300> > > > > > *From:* sr-users <[email protected]> > <mailto:[email protected]> *On Behalf Of > *Ben Kaufman > *Sent:* Tuesday, December 7, 2021 9:12 AM > *To:* Kamailio (SER) - Users Mailing List > <[email protected]> <mailto:[email protected]> > *Subject:* Re: [SR-Users] Unquoted values from #!defenv > > > > Thank you. I’ve been using -A to set values thus far as CMD > arguments to the container’s ENTRYPOINT. If submitting a pull > request, would it be preferrable to allow #!defenv/#!defenvs > to accept undefined values, or to add new keywords like > #!ifdefenv/#!ifdefenvs ? > > > > *Ben Kaufman* > > > > > *From:* Daniel-Constantin Mierla <[email protected]> > *Sent:* Tuesday, December 7, 2021 2:22 AM > *To:* Ben Kaufman <[email protected]>; Kamailio (SER) - > Users Mailing List <[email protected]> > *Subject:* Re: [SR-Users] Unquoted values from #!defenv > > > > The current behaviour targets the use of existing values from > the environment variables. If you need other kind of features, > you can propose pull requests. Or you can eventually have a > start script that sets defines with -A cli parameter based on > env variables. > > Cheers, > Daniel > > On 06.12.21 21:56, Ben Kaufman wrote: > > Thank you :) > > > > A follow up question would be on the usability of the > #!defenv (and probably #!defenvs) usability with #!ifdef. > In the scenario below, if the environmental variable > WITH_DEBUGGER is not defined, then Kamailio will fail to > start, thus the #!ifdef is somewhat limited. It makes > sense for scenarios where someone might toggle the setting > editing the config file, but it would be very convenient > to toggle the environmental variable instead, particularly > in containerized environments. Any thoughts on how best > to control this? > > > > #!defenv WITH_DEBUGGER > > > > #!ifdef WITH_DEBUGGER > > loadmodule "debugger" > > . . . > > #!endif > > > > > > > > > > *Ben Kaufman* > > > > > *From:* Daniel-Constantin Mierla <[email protected]> > <mailto:[email protected]> > *Sent:* Monday, December 6, 2021 3:55 AM > *To:* Kamailio (SER) - Users Mailing List > <[email protected]> > <mailto:[email protected]>; Ben Kaufman > <[email protected]> <mailto:[email protected]> > *Subject:* Re: [SR-Users] Unquoted values from #!defenv > > > > Hello, > > #!substdef does not set the value inside quoted string, it > replaces inside a string value, so it does not put quotes > around replacement part. So it does it it is written in > the docs. There is #!substdefs witch can create a define > with quoted value. > > Note that defines are standalone-token replacement, you > can define an ID to a number, to a keyword (e.g., src_ip), > to a quoted string or even a multi-line script snippet, like: > > #!define IDLOOP $var(i) = 0; \ > while($var(i)<5) { \ > xlog("++++ $var(i)\n"); \ > $var(i) = $var(i) + 1; \ > } > > See the core cookbook for more details. > > Anyhow, as using env variable values as quoted string is > useful and setting them with quotes might look odd, I > added #!defenvs: > > * > https://www.kamailio.org/wiki/cookbooks/devel/core#defenvs > > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kamailio.org%2Fwiki%2Fcookbooks%2Fdevel%2Fcore%23defenvs&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128674863%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=9d81Vu%2FH5XERc4ct6lzKWQYFfAqTM4gocdKD85cXclw%3D&reserved=0> > > Cheers, > Daniel > > On 30.11.21 22:40, Ben Kaufman wrote: > > Hello all, > > > > Looking for some clarification regarding quoting and > !#defenv . I understand that the example below fails > because the environmental variable HOME is not quoted, > thus when used in the xlog() call it fails. How is it > possible to evaluate and/or use the value of the > environmental variable if defined as a preprocessor > variable? Looking at the documentation the reason for > this directive is “It is a simplified alternative of > using *#!substdef* with *$env(NAME)* in the > replacement part.” But #!substdef would allow setting > the value inside of a quoted string, so does it really > meet that requirement? > > > > I’m aware that I could use $env(HOME) rather than a > preprocessor directive of HOME. I’m just trying to > understand the usage of the #!defenv feature. > > > > > > #!KAMAILIO > > ## Tested in 5.5.2 > > loadmodule "xlog" > > loadmodule "pv" > > loadmodule "evrexec" > > > > modparam("evrexec", "exec", > "name=evrexec:timer;wait=1000;workers=1;") > > > > #!defenv HOME > > > > request_route{ > > forward(); > > } > > > > event_route[evrexec:timer] { > > xlog("L_N", "HOME: " + HOME + "\n"); > > } > > > > > > *Ben Kaufman* > > > > > > > > > __________________________________________________________ > > Kamailio - Users Mailing List - Non Commercial Discussions > > * [email protected] > > Important: keep the mailing list in the recipients, do not > reply only to the sender! > > Edit mailing list options or unsubscribe: > > * > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.kamailio.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fsr-users&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128674863%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=1aEln9FgnvaQXsr1Wss%2FaQ%2BnswpBHq4MIroBz6qlV2o%3D&reserved=0> > > -- > > Daniel-Constantin Mierla -- www.asipto.com > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128684825%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=eR5%2B8tdi0htF1nwYGGza6q2XPwgEboDtDa0ZJElgEvw%3D&reserved=0> > > www.twitter.com/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128684825%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=PbG5llNVBXnJc8Fcc7E%2FXpadFK2mjZWxFs0kvSgyhUk%3D&reserved=0> > -- www.linkedin.com/in/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128694783%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=er8O94mouFO4m5OHcf3TTRHGfUFuG3%2F2B%2BFEVrc53%2Bc%3D&reserved=0> > > Kamailio Advanced Training - Online > > Feb 21-24, 2022 (America Timezone) > > * https://www.asipto.com/sw/kamailio-advanced-training-online/ > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128694783%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=DeEDkZgUBe3n2TGaABFc%2B55%2FuS2fth7N9tAAxeiSFNo%3D&reserved=0> > > -- > > Daniel-Constantin Mierla -- www.asipto.com > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128704733%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=VkMzsj6pd0pfEtfY2BxfyOTTyUX%2BxPPY0Np2rV5oXGE%3D&reserved=0> > > www.twitter.com/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128704733%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=4LaE%2F36uF6DzVCe%2BhuYu5Zg5IMz69d4nPwSeY8teofk%3D&reserved=0> > -- www.linkedin.com/in/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128704733%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=dKYae0ykIvom2lMaONUAZqhp8x3L%2Fz%2F4uZi4vhXBE1g%3D&reserved=0> > > Kamailio Advanced Training - Online > > Feb 21-24, 2022 (America Timezone) > > * https://www.asipto.com/sw/kamailio-advanced-training-online/ > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128714689%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=rBuNGZ%2FTI9B00kQY2Y0CwG3NJXR%2BVDyB0eOWZ9nWs1w%3D&reserved=0> > > > > __________________________________________________________ > > Kamailio - Users Mailing List - Non Commercial Discussions > > * [email protected] > > Important: keep the mailing list in the recipients, do not reply only > to the sender! > > Edit mailing list options or unsubscribe: > > * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.kamailio.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fsr-users&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128714689%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zU1iJ%2B2upS0T3Na1NTFKs%2BOpG3zdBekfoP%2B76jLq%2BLI%3D&reserved=0> > > -- > > Daniel-Constantin Mierla -- www.asipto.com > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128724644%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=hcUogqm2%2BFuUZOI5pF6c14V4YiosZfPEOA7kx96G46w%3D&reserved=0> > > www.twitter.com/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128724644%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=j12CODvcrVP3pgFUfvGF%2F7yFz3w4VYKVBjMFiP8nfLA%3D&reserved=0> > -- www.linkedin.com/in/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128724644%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ha2jvz9MJg3lXB5SIk0za7AaqybhEtSPrLBV9YzfiNk%3D&reserved=0> > > Kamailio Advanced Training - Online > > Feb 21-24, 2022 (America Timezone) > > * https://www.asipto.com/sw/kamailio-advanced-training-online/ > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128734601%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=8WhFiOVmFPvJWGNKt%2Brx7tMyiDQAEKQberi3X8fzQFw%3D&reserved=0> > > -- > Daniel-Constantin Mierla -- www.asipto.com > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128734601%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=I%2FVyekNXiGlr%2FBMAC0qP%2BEwcEuch5Qp5h1wWdfzrgDg%3D&reserved=0> > www.twitter.com/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128744557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=cIoP6XrSx967nOstB2bPihL7wFfuDSzjXwGfg505Sy4%3D&reserved=0> > -- www.linkedin.com/in/miconda > <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128744557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=x1xJQspvFwZL367XcM75INoWIOwgn8DWRPtlskzbB5g%3D&reserved=0> > Kamailio Advanced Training - Online > Feb 21-24, 2022 (America Timezone) > * https://www.asipto.com/sw/kamailio-advanced-training-online/ > <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Cbkaufman%40bcmone.com%7C7f2519a79bfe44fe14b108d9baf9fcfc%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637746405128754515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=o6Iy%2BLubXZTQi6NcWHC4yL81cUhp2lNfSEr3OarZVo8%3D&reserved=0> > > __________________________________________________________ > Kamailio - Users Mailing List - Non Commercial Discussions > * [email protected] > Important: keep the mailing list in the recipients, do not reply only to the > sender! > Edit mailing list options or unsubscribe: > * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Online Feb 21-24, 2022 (America Timezone) * https://www.asipto.com/sw/kamailio-advanced-training-online/
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions * [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
