[SR-Users] Unable to pull enviornment variables

Adarsh Chauhan adarshchauhan at hotmail.com
Wed Sep 22 08:43:26 CEST 2021

Hi Daniel,

I figured it's related to the way I start kamailio, using sudo.

My kamailio version is 5.5.x

But I am confused what you mean by next construction is not supported because it seems to be working if I use

#!ifdef DEVSTAGE == "dev"


Get Outlook for Android<https://aka.ms/AAb9ysg>

From: Daniel-Constantin Mierla <miconda at gmail.com>
Sent: Wednesday, 22 September, 2021, 11:50 am
To: Kamailio (SER) - Users Mailing List; Adarsh Chauhan
Subject: Re: [SR-Users] Unable to pull enviornment variables


what version of Kamailio do you use? How do you start Kamailio?

Anyhow, note that the next construction is not supported:

#!ifdef DEVSTAGE == "dev"


On 21.09.21 11:13, Adarsh Chauhan wrote:
Hi Team,

Need some help here.
Want to pull environment variable however kamailio just doesnt pick it.

I exported the environment variable
export STAGE="dev"

Then i tried following
#!defenv DEVSTAGE
gives error
 0(3809) ERROR: <core> [core/cfg.lex:2085]: pp_define_env(): env variable not defined [DEVSTAGE]

#!substdef "/DEVSTAGE/$env(DEVSTAGE)/";

 0(3962) DEBUG: <core> [core/ppcfg.c:87]: pp_subst_add(): ### added subst expression: [/DEVSTAGE/$env(DEVSTAGE)/]
 0(3962) DEBUG: <core> [core/cfg.lex:1964]: pp_define(): defining id: DEVSTAGE
 0(3962) DEBUG: <core> [core/parser/parse_fline.c:249]: parse_first_line(): first line type 1 (request) flags 1
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:677]: parse_msg(): SIP Request:
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:679]: parse_msg():  method:  <OPTIONS>
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:681]: parse_msg():  uri:     <sip:you at kamailio.org<mailto:sip%3Ayou at kamailio.org>>
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:683]: parse_msg():  version: <SIP/2.0>
 0(3962) DEBUG: <core> [core/parser/parse_hname2.c:293]: parse_sip_header_name(): parsed header name [Via] type 1
 0(3962) DEBUG: <core> [core/parser/parse_via.c:2639]: parse_via(): end of header reached, state=2
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:555]: parse_headers(): Via found, flags=2
 0(3962) DEBUG: <core> [core/parser/msg_parser.c:557]: parse_headers(): this is the first via
 0(3962) DEBUG: <core> [core/pvapi.c:497]: pv_spec_lookup(): PV <$env(DEVSTAGE)> is not in cache
 0(3962) DEBUG: <core> [core/pvapi.c:335]: pv_cache_add(): PV cache not initialized, doing it now
 0(3962) DEBUG: <core> [core/pvapi.c:371]: pv_cache_add(): pvar [$env(DEVSTAGE)] added in cache
 0(3962) DEBUG: <core> [core/cfg.lex:2053]: pp_define_set(): ### setting define ID [DEVSTAGE] value [<null>] (mode: 1)
 0(3962) DEBUG: <core> [core/ppcfg.c:188]: pp_substdef_add(): ### added substdef: [DEVSTAGE]=[<null>] (0)
 0(3962) DEBUG: <core> [core/re.c:436]: subst_run(): running. r=1
 0(3962) DEBUG: <core> [core/re.c:504]: subst_str(): no match
 0(3962) DEBUG: <core> [core/re.c:436]: subst_run(): running. r=1
 0(3962) DEBUG: <core> [core/re.c:504]: subst_str(): no match

my end goal is to compare the directive and load modules accordingly.
#!ifdef DEVSTAGE == "dev"

Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
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<http://www.asipto.com>
www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>
Kamailio Advanced Training - Online
Nov 08-11, 2021 (Europe Timezone) - Nov 22-25, 2021 (America Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210922/89decd86/attachment.htm>

More information about the sr-users mailing list