Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

will this work?:

tail -f /var/log/messages  | sed 's/^/\a/'
share|improve this answer
    
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
add comment

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.

share|improve this answer
    
Cool app I'll make note of perhaps for future use. Thx. –  eflat Dec 20 '10 at 20:55
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.