Re: awk question (actively tail a file & notify when expression is found)
On Wed, 22 Apr 2009 12:38:47 -0700, Evuraan::ഏവൂരാന് wrote: > but this below, does not work > > tail -f /var/log/apache2/access.log |awk ' /192.168.1.100/ { print > $0 | "mail m...@email.address "}' I would suggest to keep the system() approach: tail -f /var/log/apache2/access.log | awk '/192.168.1.100/ { system(sprintf("echo %s | mail m...@email.address", $0)); }' > Any pointers would be much appreciated. It should work, but I'm sure someonle else will soon show you some more elegant way. :-) -- Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: awk question (actively tail a file & notify when expression is found)
nevermind, i got it to work, with a little help from http://student.northpark.edu/pemente/awk/awk_sys.txt, tail -f /var/log/apache2/access.log | awk '/192.168.1.100/ {system("echo " $0 "| mailx -s test_email m...@email.com" ) }' thx..! 2009/4/22 Bill Campbell : > You might want to look at ``swatch'' which is designed to do > this, and monitors multiple log files simultaneously. > > On Wed, Apr 22, 2009, Evuraan:: wrote: >>Greetings..! >> >>this 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\" m...@email.address")}' >> >>but this below, does not work >> >> tail -f /var/log/apache2/access.log |awk ' /192.168.1.100/ { print >>$0 | "mail m...@email.address "}' >> >>Any pointers would be much appreciated. >> >>Thx. >>___ >>freebsd-questions@freebsd.org mailing list >>http://lists.freebsd.org/mailman/listinfo/freebsd-questions >>To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org" >> > > -- > Bill > -- > INTERNET: b...@celestial.com Bill Campbell; Celestial Software LLC > URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way > Voice: (206) 236-1676 Mercer Island, WA 98040-0820 > Fax: (206) 232-9186 Skype: jwccsllc (206) 855-5792 > > Capitalism works primarily because most of the ways that a company can be > scum end up being extremely bad for business when there's working > competition. -rra > ___ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org" > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: awk question (actively tail a file & notify when expression is found)
You might want to look at ``swatch'' which is designed to do this, and monitors multiple log files simultaneously. On Wed, Apr 22, 2009, Evuraan:: wrote: >Greetings..! > >this 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\" m...@email.address")}' > >but this below, does not work > > tail -f /var/log/apache2/access.log |awk ' /192.168.1.100/ { print >$0 | "mail m...@email.address "}' > >Any pointers would be much appreciated. > >Thx. >___ >freebsd-questions@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-questions >To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org" > -- Bill -- INTERNET: b...@celestial.com Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax:(206) 232-9186 Skype: jwccsllc (206) 855-5792 Capitalism works primarily because most of the ways that a company can be scum end up being extremely bad for business when there's working competition. -rra ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"