[plug] clear the screen when using the watch utility

Craig Ringer craig at postnewspapers.com.au
Sat Oct 29 11:11:17 WST 2005


W.Kenworthy wrote:
> Try it, it dosnt work!
> 
> I use watch to run "ntp -p" and some other monitor commands.  The
> problem is when I change networks and therefore ntp servers, the number
> of servers changes, so ntp writes to a different place on the screen
> without clearing the previous.  Another problem is when the network is
> unreachable, the data is unreadable.  Run 'watch ntp -p' and stop the
> ntp daemon, wait a few seconds and restart ntp and you will see what I
> mean.
> 
> So every refresh period (2 secs), I want to clear the screen before ntp
> writes to the screen.

I still don't really see why Tim's suggestion won't do the trick - use:
     watch "clear; ntp -p"
It works just fine here, though I haven't tested the case of an 
unreachable network.

> Think I'll use perl: as far as I can see watch cant deal with this.

Nope, but it's easy enough to handle in the shell:

while : ; do
     clear
     ntp -p
     sleep 2
done

Again, not sure about unreachable network though.

--
Craig Ringer



More information about the plug mailing list