I'm writing scripts in perl and shell and want to add the oprion of
scrolling cursor on the screen when there is no output to the screen for long time. I saw it in some script but I don't have the source code.
The simple method is to add a check for ever piece of code that might output data. But if you rely on a sub-process that might never return, this doesn't work too well.
The complex method is to set up a timer and trap the timer with something that outputs to the screen. The trap can check a variable before printing; that variable is reset every time there is output.
This demonstrates (in BASH) the basic concept:
wake_up() {
echo "++ Waiting for more input ++"
}
trap wake_up SIGALRM
( while true; do kill -SIGALRM $$; sleep 30; done ) &
date
sleep 90;
date
sleep 90;
date