我的目标:在目录上创建文件时运行 Rscript/home/gabriel/data
这就是我所拥有的inotiwait
$ inotifywait -m -e create /home/gabriel/data |
while read -r filename event; do
Rscript /home/gabriel/script/updatedb.R;
done
我首先在终端上运行这些行,然后在/home/gabriel/data
. 创建文件后,我可以清楚地看到我的 Rscript 运行正确,因为数据库得到了更新。
但是,当我在 bash 中使用相同的代码时,我的 Rscript 无法运行。这是我的狂欢:
#!/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.
我打电话inotifytest.sh
并保存在/home/gabriel
. 我允许执行这个 bash:
$ chmod +x inotifytest.sh
然后开始运行 bash:
$ sh inotifytest.sh
: not found.sh: 2: inotifytest.sh:
Setting up watches.
Watches established.
当我创建新文件时,我的数据库没有得到更新,这意味着我的 Rscript 没有运行。
我可能在很多层面都做错了,但我看不出在哪里。谢谢您的帮助。