My goal: run a Rscript when a file is created on directory /home/gabriel/data
Here's what I have with inotiwait
$ inotifywait -m -e create /home/gabriel/data |
while read -r filename event; do
Rscript /home/gabriel/script/updatedb.R;
done
I first run these lines on terminal, then create one new file on /home/gabriel/data
. When the file is created, I can clearly see that my Rscript ran correctly because a database gets updated.
However, when I but the same code in bash I don't get my Rscript to run. Here's my bash:
#!/bin/sh
inotifywait -m -e create /home/gabriel/data |
while read -r filename event; do
Rscript /home/gabriel/script/updatedb.R;
done
Setting up watches.
Watches established.
Which I call inotifytest.sh
and saved on /home/gabriel
. I gave permission for this bash to be executed:
$ chmod +x inotifytest.sh
And then start running the bash:
$ sh inotifytest.sh
: not found.sh: 2: inotifytest.sh:
Setting up watches.
Watches established.
When I create new files, my database does not get updated which means that my Rscript did not run.
I'm probably doing it wrong in many levels but I don't see where. Thank you for your help.