# Exporting environment variables from startup.options doesn't work

**URL:** <https://discuss.elastic.co/t/exporting-environment-variables-from-startup-options-doesnt-work/86570>\
**Category:** Logstash\
**Created:** [May 21, 2017, 2:02pm UTC](https://discuss.elastic.co/t/exporting-environment-variables-from-startup-options-doesnt-work/86570 "2017-05-21T14:02:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harelmoshe1](https://avatars.discourse-cdn.com/v4/letter/h/3ec8ea/32.png) [@harelmoshe1](https://discuss.elastic.co/u/harelmoshe1)\
**Post date:** [May 21, 2017, 2:02pm UTC](https://discuss.elastic.co/t/exporting-environment-variables-from-startup-options-doesnt-work/86570/1 "2017-05-21T14:02:16Z")

</div>

Hi,

I'm trying to implement the following solution using chef, in which the startup.options file looks as follows:

```
...
read -r -d '' PRESTART << EOM
 export A=1
 export B=2
 export C=3
EOM
...

```

Then, I'm starting the logstash service through chef's _service_ (which is probably systemctl, as I'm running CentOS 7.0) with the logstash.yml file referring to the correct logstash.conf file in another folder.

However, the environment variables I export on the PRESTART part of the startup.options doesn't seem to be exported well, as I get an error in the log saying:

`Cannot create pipeline {:reason=>"Cannot evaluate`${MY\_ENV\_VAR}`. Environment variable`MY\_ENV\_VAR`is not set and there is no default value given."}`

Any idea what might be the cause for the environment variables not available to logstash even though they are exported in its own startup.options file?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 18, 2017, 2:02pm UTC](https://discuss.elastic.co/t/exporting-environment-variables-from-startup-options-doesnt-work/86570/2 "2017-06-18T14:02:28Z")

</div>

Closed on June 18, 2017, 2:02pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
