# Input plugin for returning directory contents having ".xyz" extension

**URL:** <https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515>\
**Category:** Logstash\
**Created:** [April 18, 2018, 10:41am UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515 "2018-04-18T10:41:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![codelearner](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@codelearner](https://discuss.elastic.co/u/codelearner)\
**Post date:** [April 18, 2018, 10:41am UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/1 "2018-04-18T10:41:40Z")

</div>

I need to return the file names only, from a particular directory as soon as the file is getting created. i tried using "exec" input plugin for this. For achieveing this i wrote a shell script as below :

(cd /home/development/DEMO/ && ls \*.stdout) \> /tmp/watchfile ; while true; do (cd /home/development/DEMO/ && ls \*.stdout) \> /tmp/watchfile2 ; diff -q /tmp/watchfile /tmp/watchfile2 \> /dev/null ; if [$? -ne 0] ; then echo "File list changed" ; echo diff /tmp/watchfile /tmp/watchfile2; fi ; cp /tmp/watchfile2 /tmp/watchfile ; done

Note : the second echo is under accent graves but not showing here properly !  
The script is working fine through terminal, but when i try to put this in exec input plugin its throwing error.  
Please suggest how can i achieve this or is their some other plugin i can modifiy & use like the "file" input plugin. Thanks in advance

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 18, 2018, 11:11am UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/2 "2018-04-18T11:11:12Z")

</div>

Don't _describe_ what you did, _show_ us (including any error messages).

---

<div class="post-metadata">

**Author:** ![codelearner](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@codelearner](https://discuss.elastic.co/u/codelearner)\
**Post date:** [April 18, 2018, 11:54am UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/3 "2018-04-18T11:54:32Z")

</div>

Hi magnusbaeck,

basically i am trying this:

`sudo ./bin/logstash --debug -e 'input{exec{command => 'ls' interval => 5}} output {stdout{}}' --path.data LOGSTASH_HOME/test88`

but instead of a single command for exec input plugin i have given an entire script in one line with "; ".  
I thought if a single command is working why not can i give a whole script. But its not working as u can see here :

 ![4](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4b5944293354f84144b5acaf13ace2c9e7c6bdde.png)

its giving me a prompt sign. Can u help !

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 19, 2018, 6:10am UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/4 "2018-04-19T06:10:24Z")

</div>

You're single-quoting the whole argument to `-e`. Then you can't use single quotes inside the command.

It'll be much easier and more readable if you put your shell commands in a script file and run that.

---

<div class="post-metadata">

**Author:** ![codelearner](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@codelearner](https://discuss.elastic.co/u/codelearner)\
**Post date:** [April 19, 2018, 3:51pm UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/5 "2018-04-19T15:51:21Z")

</div>

Hi magnusbaeck,  
Thanks for replying , i put the script in a file and it is running fine now.  
Thanks for the help once again.

Here is my code :

 ![5](https://us1.discourse-cdn.com/elastic/original/3X/4/4/443b5c3f7bac12ff6c8eb8fef77861edef55c292.png)

---

<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:** [May 17, 2018, 3:51pm UTC](https://discuss.elastic.co/t/input-plugin-for-returning-directory-contents-having-xyz-extension/128515/6 "2018-05-17T15:51:30Z")

</div>

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