8 Ekim 2012 Pazartesi

Batch - Run A Command Repeatedly In Each N Seconds

Sometimes you need to execute some command repeatedly in each n second(s). May be, you are listening a change on a file, a database or something another. If you don't want to fire same command again and again manually, you can use my listen.bat script. For example, you can check count of needles in the :
listen 3 grep "needle" "haystack.txt" -c

Script is below (gist here):
@echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: This script executes given command repeatedly.
:: Waits specified amount of time between two executions.
:: First parameter MUST be sleep time.
:: Rest of the parameters will be executed as a command.
:: This script relies on sleep command from GnuWin32 package.
:: 
:: usage: (1 minute = 60 seconds intervals. More info: sleep --help)
::    listen 60  grep -w needle "haystack.txt"
::    listen 60s grep -w needle "haystack.txt"
::    listen  1m grep -w needle "haystack.txt"
::
:: @author: mmdemirbas@gmail.com
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: First argument is expected to be sleep time
set SLEEP_TIME=%1

:: Other arguments will be a command with or without some parameter(s)
set command=
:init
shift
if [%1]==[] goto exec
set command=%command% %1
goto init

:exec
 call %command%
 sleep %SLEEP_TIME%
goto exec

Hiç yorum yok:

WSO2 ESB + ClientAccesPolicy.xml + CrossDomain.xml

ClientAccesPolicy.xml and CrossDomain.xml files have to be found at root of your services Silverlight and Flex clients to be able to acce...