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

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

Don't describe what you did, show us (including any error messages).

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 :

its giving me a prompt sign. Can u help !

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.

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 :

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