Prev: HPSBUX02523 SSRT100036 rev.1 - HP-UX Running ONCPlus, Remote Denial of Service (DoS), Increase in Privilege
Next: Frontend for WiFi setup
From: hehehe on 27 May 2010 03:08 Hello! I`d like to know if its possible to do: tail -f test.log | grep Exception and when Exception appear script will be executed... any idea? Regards
From: pk on 27 May 2010 06:35 hehehe wrote: > Hello! > > I`d like to know if its possible to do: tail -f test.log | > grep > Exception > and when Exception appear script will be executed... any idea? not with grep, but you can implement something like this tail -f test.log | while IFS= read -r line; do if echo "$line" | grep -q Exception; then # do whatever here... fi done
From: hehehe on 27 May 2010 06:58 Uzytkownik "pk" <pk(a)pk.invalid> napisal w wiadomosci news:2413074.LiZASKD2KP(a)xkzjympik... > hehehe wrote: > >> Hello! >> >> I`d like to know if its possible to do: tail -f test.log | >> grep >> Exception >> and when Exception appear script will be executed... any idea? > > not with grep, but you can implement something like this > > tail -f test.log | while IFS= read -r line; do > if echo "$line" | grep -q Exception; then > # do whatever here... > fi > done > thx
From: Chris F.A. Johnson on 27 May 2010 14:45
On 2010-05-27, pk wrote: > hehehe wrote: > >> Hello! >> >> I`d like to know if its possible to do: tail -f test.log | >> grep >> Exception >> and when Exception appear script will be executed... any idea? > > not with grep, but you can implement something like this > > tail -f test.log | while IFS= read -r line; do > if echo "$line" | grep -q Exception; then > # do whatever here... > fi > done There's no need for grep: tail -f test.log | while IFS= read -r line; do case $line in *Exception*) # do whatever here ... ;; esac done -- Chris F.A. Johnson, <http://cfajohnson.com> Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) |