Last active
August 29, 2015 14:21
-
-
Save cypok/c9d1eff84ff59ccafa63 to your computer and use it in GitHub Desktop.
Analog of watch (GNU command-line tool) for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo OFF | |
REM watch is a GNU command-line tool that runs the specified command repeatedly | |
REM and displays the output on stdout so you can watch it change over time. | |
REM By default, the command is run every two seconds, although this is adjustable with the -n secs argument. | |
if x%1==x (call :usage %0 %* && exit /b 1) | |
if x%1==x-n ( | |
if x%2==x (call :usage %0 %* && exit /b 1) | |
for /f "tokens=2*" %%a in ("%*") do ( | |
rem ignore %%a==-n | |
set INTERVAL=%%a | |
set CMD=%%b | |
) | |
) else ( | |
set INTERVAL=2 | |
set CMD=%* | |
) | |
:run | |
cls | |
@echo ON | |
%CMD% | |
@echo OFF | |
if errorlevel 1 ( goto :EOF ) | |
timeout /t %INTERVAL% >nul 2>&1 | |
goto :run | |
:usage | |
echo Usage: %1 [-n ^<seconds^>] ^<command with args^> | |
goto :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment