Hello,
I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe.
There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file.
cat test.sh
#############
mail -s mail -s "New upload : $1"
test@test.tld
will email the filename to external email address.
now in test.sh I want to perform multiple functions:
1) email the uploaded file name ( which is done above )
2) grep/awk etc, for a string or word in the uploaded file and then
if
the exact word or string is found
then
do
grep -nr "$pattern" $1
echo " Following pattern found in file" $1 at line number >> /root/upload.log
/bin/rm -fr $1
else
echo "File safe: " $1 >> /root/upload.log
Now the pattern or word can be anyone of the following:
porn viagara cannibal maneater herbivore verygood millioniare donkey
so pattern is something like
pattern='porn|viagara|cannibal|maneater|herbivore|verygood|millioniare|donkey'
Please advise.
Thanks