@echo offIf you want to use it, copy the script above into a file called 'watch.cmd' and place that file somewhere in your path, e.g. C:\Windows\System32.
title Watching %1 %2 %3 %4 %5
:top
cls
%1 %2 %3 %4 %5
echo.
choice /C QC /M "Press Q to quit or C to continue" /t 3 /d c
if errorlevel==2 goto top
if errorlevel==1 goto end
:end
What happens in the script above is basically that the 1st parameter you supply would be the command to run and the following 4 parameters would be any switches or values you want to provide. Up to 4 extra switches can be provided although you can obviously change this to be as many as you like. The choice command provides a 3-second delay and gives you the chance to quit watching by pressing q or continue immediately by pressing c — rather than waiting for the 3 seconds to elapse. Again, you can change the timeout from 3 seconds by changing the /t 3 value to something else.
Now, say you want to monitor the output of a file named 'C:\error.log'. Use the command by entering watch type c:\error.log and the file will be repeatedly typed on the console screen at 3 second intervals until you press q.
Easy!
No comments:
Post a Comment