5

I have a putty session tailing a log. I either keep flipping to it to see in anything has come up or I forget to check it at all. Can putty or tail be made to "beep" if anything scrolls into the window?

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
eflat
  • 173
  • 1
  • 5

3 Answers3

8

will this work?:

tail -f /var/log/messages  | sed 's/^/\a/'
Jeff Atwood
  • 13,104
  • 20
  • 75
  • 92
mgjk
  • 874
  • 3
  • 9
  • 20
  • This is so close! It works as it is, but I'd like to filter out some routine messages that come up so I pipe to grep -v first. Full thing looks like "tail -f server.log | grep -v "Invalid chunk ignored." | sed 's/^/\a/'" and it looks like it's buffering before piping to sed. Hmmmm....it just did beep but it looks like it buffered a bunch of messages. Maybe took a couple minutes. That might be "good enough", though I'll watch it to see if it's consistent enough. – eflat Dec 20 '10 at 20:50
  • It seems to be buffering 22-23 lines before it sends output to window and beeps. That behavior ring a bell (no pun!) for anyone? – eflat Dec 20 '10 at 21:36
  • Thanks to another answered question on SO, I found that this works: tail -f server.log | while read line ; do echo "$line" | grep -v "Invalid chunk ignored." | sed 's/^/\a/'; done – eflat Dec 20 '10 at 21:59
  • @eflat: Try using `grep --line-buffered -v ...` without the `while` loop. – Dennis Williamson Dec 20 '10 at 22:57
7

MultiTail has an option to do that:

--beep-interval x
Let the terminal beep for every x-th line processed. Press 'i' in the main menu to see how many times it beeped.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
3

This answer is slightly off to the side of your question but that's as much as I can help.

First I don't know of a simple way for tail or putty to alert you when data gets moving.

Second you need to enable beeps in Putty: check the option to pass on any bell call from the terminal session (check your settings -> terminal -> Bell). You may want to select a wav file there (or select 'flash the screen' for testing purposes).

Test it by typing control-G in the putty terminal window. So now you should have a bell that works.

Lastly, one option might be to pipe your tail to some script that checks the time for each line input (awk, perl or ruby come to mind, though I'm sure the shell would do just as well) and output a \x07 to /dev/stderr if the time difference between two consecutive outputs is greater than a given number of seconds.

For example:

(yourscript) | awk '{pt=t; t=systime(); if ((t-pt)>10) {printf "\x07" > "/dev/stderr"}; print}'

e.g.

(echo a; sleep 4; echo b; sleep 9; echo c; sleep 12; echo d; sleep 8; echo e) | awk '{pt=t; t=systime(); if ((t-pt)>10) {printf "\x07" > "/dev/stderr"}; print}'

Change 10 in the awk script to the amount of seconds you want to wait for data before beeping the terminal.

asoundmove
  • 266
  • 1
  • 2
  • 6