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?

3 Answers 3

8

will this work?:

tail -f /var/log/messages  | sed 's/^/\a/'
4
  • 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, 2010 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, 2010 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, 2010 at 21:59
  • @eflat: Try using grep --line-buffered -v ... without the while loop. Dec 20, 2010 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.

1
  • Cool app I'll make note of perhaps for future use. Thx.
    – eflat
    Dec 20, 2010 at 20:55
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .