awk filtering, then execution

Hi,

I need to do the following but I don't know exactly what to do.

I need to monitor a file ... with tail -f for example, but I know that I could do it with awk, wait for a specific string ... , then perform an action, call a script, etc.

Let's say that my file name is test.txt , I need to wait for a string like "system call" ... if that happens, I will take that file to another place, or email, etc.

How can I do it from the CLI, without using additiona scripts, etc?

Thanks,

Marco

On the top of my head, no debugging done, using bash since I've no idea how to call different programs from awk:

tail -f test.txt | while read D ; do if [ "$D" = "mail this file to me" ] ; then mail -s "keyword mentioned in log" some.email@host.com < test.txt ; fi ; done

While on another terminal

echo "mail this file to me" > test.txt

will get the insides of file test.txt sent to some.email@host.com.

Some adjusts

tail -f test.txt | while read D ; do echo "$D" |grep "PUT YOUR STRING HERE" ; if [ $? == "0" ];   then mailx -s "keyword mentioned in log" some.email@host.com < test.txt ; fi ; done

Thanks for the reply ... it worked fine !