awk : actively tail a file & email when criteria is met
Loïc Grenié
loic.grenie at gmail.com
Wed Apr 22 20:01:27 UTC 2009
2009/4/22 Evuraan::ഏവൂരാന് <evuraan at gmail.com>:
> Greetings..!
>
> this below works:
>
> tail -f /var/log/apache2/access.log | \
> nawk '/192.168.1.100/{ print $0 }'
>
> and this too:
>
> tail -f /var/log/apache2/access.log | \
> awk ' /192.168.1.100/ { system ("mail -s \"This works\" me at email.address")}'
>
> but this below, does not work:
>
> tail -f /var/log/apache2/access.log | \
> awk ' /192.168.1.100/ { print $0 | "mail me at email.address "}'
>
> I tried nawk,gawk etc. still no go.
The line above is missing a "system()" :
tail -f /var/log/apache2/access.log | \
awk ' /192.168.1.100/ { print $0 | system("mail me at email.address "); }'
Does it solve your problem ? Otherwise, could you specify exactly
what is your problem ? (Command does not start, e-mail received
is incorrect, etc...)
Hope this helps,
Loïc
More information about the ubuntu-users
mailing list