Nice catch! That could be indeed the problem.

Cheers,
Daniel

On 22.09.21 14:16, Ben Kaufman wrote:
Am I misreading, or is this a defined environmental variable named "STAGE" but you're evaluating an environmental variable named "DEVSTAGE"?

Ben Kaufman

Sr. VoIP Engineer


P:

E: bkaufman@nexvortex.com

24 hour client support: 855.639.6300

 

image  image  image  image


NOTE: This e-mail and any attachments are from nexVortex, Inc. and are intended solely for the use and review of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail (and any attachment




From: sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Adarsh Chauhan <adarshchauhan@hotmail.com>
Sent: Wednesday, September 22, 2021, 1:04 AM
To: sr-users@lists.kamailio.org
Subject: [SR-Users] Unable to pull enviornment variables

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
1)
#!defenv DEVSTAGE
gives error
 0(3809) ERROR: <core> [core/cfg.lex:2085]: pp_define_env(): env variable not defined [DEVSTAGE] 

2) 
#!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@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@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
www.twitter.com/miconda -- 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/