Reputation: 136
I want to get an email alert if a certain folder is modified but how do I pipe the output from the command so it sends an email not just show the changes to the folder in the terminal?
something like the following but... gives an error on the email part
inotifywait -m /home/tom -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
| /usr/bin/Mail -s "notify" "[email protected]"
done
Upvotes: 3
Views: 2621
Reputation: 1267
Could it be you simply missed the semicolon before done
?
This line works for me (note I also used mutt
instead of Mail
):
inotifywait -m /home/tom -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" | /usr/bin/mutt -s "notify" "[email protected]" ;done
Upvotes: 3