# Use eval with exec pluging

**URL:** <https://discuss.elastic.co/t/use-eval-with-exec-pluging/154400>\
**Category:** Logstash\
**Created:** [October 29, 2018, 8:17am UTC](https://discuss.elastic.co/t/use-eval-with-exec-pluging/154400 "2018-10-29T08:17:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [October 29, 2018, 8:17am UTC](https://discuss.elastic.co/t/use-eval-with-exec-pluging/154400/1 "2018-10-29T08:17:37Z")

</div>

I have a perl script when I source it on my Linux shell (through the command eval `a.pl` ) it set few env variables. Now I need to source this file with logstash input file inside exec plugin. I tried the following but it doesn't work.

input {

exec {

command ='eval a.pl;/opt/awz --mshosts | sed -e s/host/hostname/g | sed -e s/type/ostype/g'

interval =86400

type =\> "xyz-mshost"

codec =\> json\_lines

add\_field =\> { "clustername" =\> "testcluster" }  
}  
}

In command variable I am passing "mshosts" as an argument to script "/opt/awz" and this mshosts variable is set through the perl script (a.pl). When I run this complete command (eval `a.pl` ;/opt/awz --mshosts | sed -e s/host/hostname/g | sed -e s/type/ostype/g) on Linux shell it's working fine but not working through json input file.

If I use a shell script instead of perl to source the env variable for above command that one also works fine. Issue is when I pass perl script to source few env variable.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2018, 8:26am UTC](https://discuss.elastic.co/t/use-eval-with-exec-pluging/154400/2 "2018-10-29T08:26:36Z")

</div>

This seems to be a duplicate of [this thread](https://discuss.elastic.co/t/source-perl-script-in-logstash-input-conf-file/153955). Please do not open multiple threads for the same question.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2018, 8:26am UTC](https://discuss.elastic.co/t/use-eval-with-exec-pluging/154400/3 "2018-10-29T08:26:48Z")

</div>


