0

I would like to get "file", "dir" and "action" variables from inotifywait and get them into "script.sh" to use them later on, if anyone can help:

 inotifywait -m PATH/TO/UPLOADS -e create -e moved_to |
 while read -r dir action file; do
 sh /root/script.sh
/*****
 ***** Some codes goes here
*****/

Thanks in advance

  • i'm not sure i understand correctly, but you can pass them like this, /root/script.sh "$dir" "$action" "$file", then read them inside the script echo "$1", echo "$2", echo "$3" – DamianK Apr 07 '20 at 16:18
  • @DamianK: Thanks for the reply I would like to get these 3 variables from "file1.sh" to use them in "/root/script.sh" – Immo Broker Apr 07 '20 at 16:27
  • So use example from my previous comment, or read more about here https://unix.stackexchange.com/questions/31414/how-can-i-pass-a-command-line-argument-into-a-shell-script – DamianK Apr 07 '20 at 16:30
  • Thanks @DamianK, It works like a charm – Immo Broker Apr 09 '20 at 14:08

0 Answers0