# Environment Variable in "run" for adef file

**URL:** <https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475>\
**Category:** Uncategorized\
**Created:** [March 31, 2023, 3:18pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475 "2023-03-31T15:18:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [March 31, 2023, 3:18pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475/1 "2023-03-31T15:18:22Z")

</div>

Hi, not sure what I am getting wrong. I use environment variables in my build and use them in the adef and other xdef files.

But I have a scenario where the environment variable is not being replaced with its value for the processes-\>run section, however it is being resolved further down in the required-\>device section.

I use the env var (MY\_ENV\_VAR) as follows

```auto
executables:
{
	App1= (AppComponent)
}

processes:
{
	envVars:
	{
		LE_LOG_LEVEL = DEBUG
	}

	run:
	{
		( set-iptables.sh)
		( App1 -start ${MY_ENV_VAR} )
	}
	faultAction: restartApp
	maxCoreDumpFileBytes: 512K
	maxFileBytes: 512K
}

```

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 31, 2023, 3:39pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475/2 "2023-03-31T15:39:39Z")

</div>

where is the MY\_ENV\_VAR defined?

Here is an example of putting argument to the application:

> <https://github.com/legatoproject/legato-af/blob/master/apps/sample/modemDemo/modemDemo.adef>

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [March 31, 2023, 3:45pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475/3 "2023-03-31T15:45:54Z")

</div>

MY\_ENV\_VAR is set outside in the shell when the app is built… as I said it is available as the other part of the adef resolves it correctly… however I need to pass it into the application through the command line argument… which I can do statically… but I want my command line argument to be dynamic and based on the environment variable at build time…

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [March 31, 2023, 4:21pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475/4 "2023-03-31T16:21:22Z")

</div>

then can you make a script to generate the adef everytime before the app is built?

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [March 31, 2023, 4:23pm UTC](https://forum.legato.io/t/environment-variable-in-run-for-adef-file/6475/5 "2023-03-31T16:23:23Z")

</div>

It seems the env vars in the exec section cannot be expanded… it is a pity as I’d prefer to just pass in the settings…

I am working around this by using the #if options… its not ideal… but will work…
