@echo off rem sbinit rem See the :help function below for documentation rem option defaults set port= set uri= set sbdwait=0 set verbose= set args= rem handle command line switches :loop_args if {%1}=={} goto :done_args set _this_arg=%1 set _this_arg=%_this_arg:"=% if not "%_this_arg:~0,1%"=="-" goto :done_args shift /1 if "%_this_arg:~0,1%"=="-" ( if /i "%_this_arg:~1,1%"=="p" (set args=%args% -p %1& shift /1 ) if /i "%_this_arg:~1,1%"=="u" (set args=%args% -u %1& shift /1 ) if /i "%_this_arg:~1,1%"=="v" set verbose=1 if /i "%_this_arg:~1,1%"=="w" set sbdwait=1 if /i "%_this_arg:~1,1%"=="h" (call :usage & call :help & goto :EOF) if "%_this_arg:~1,1%"=="?" (call :usage & call :help & goto :EOF) ) goto :loop_args :done_args if "%sbdwait%"=="1" call :sbwait set init_dir=%1 if "%init_dir%"=="" goto :EOF if not exist %init_dir% ( echo %init_dir% does not exist. & goto :EOF ) pushd %init_dir% rem priority prefixes not implemented for Windows rem enqueue to the the streams in no particular order for %%i in (*.*) do @call :enq %%i goto :done :enq if "%verbose%"=="1" echo %1 sbc %args% enqueue %1< %1 goto :EOF :done popd goto :EOF rem Functions :usage echo Usage: sbinit [-p ^] [-u ^] [-v] [-w] [dir] >&2 goto :EOF :help echo. >&2 echo ^ ^ ^ ^ -p ^ >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ Equivalent to '-u sb://localhost:^/' echo ^ ^ ^ ^ -u ^ echo ^ ^ ^ ^ ^ ^ ^ ^ Set URI of the StreamBase server ^(default: echo ^ ^ ^ ^ ^ ^ ^ ^ sb://localhost:10000/^). May also be set using the echo ^ ^ ^ ^ ^ ^ ^ ^ STREAMBASE_SERVER environment variable echo ^ ^ ^ ^ -v echo ^ ^ ^ ^ ^ ^ ^ ^ Verbose mode ^(prints out names of files just prior to enqueueing^) echo ^ ^ ^ ^ -w echo ^ ^ ^ ^ ^ ^ ^ ^ Wait for the StreamBase server to listen echo ^ ^ ^ ^ dir echo ^ ^ ^ ^ ^ ^ ^ ^ Directory in which CSV files reside. echo. >&2 echo sbinit optionally waits for a StreamBase server to start listening, >&2 echo and then enqueues a set of data files to the server's Input Streams. >&2 echo The data files must have the same name as the target streams. >&2 echo If the data file's names are prefixed with a number plus a dot, >&2 echo then the number signifies a priority ordering. File names prefixed with >&2 echo lower numbers are enqueued before files prefixed with higher numbers. >&2 echo. >&2 echo Priority prefixes are not supported on Windows. >&2 goto :EOF :sbwait rem wait for shutdown :sbwait_loop sbc %args% status > nul 2>&1 if %ERRORLEVEL% EQU 0 goto :sbwait_done sleep 1 goto :sbwait_loop :sbwait_done goto :EOF :sbcheck rem check for sbd listening sbc %args% status > nul 2>&1 if %ERRORLEVEL% EQU 0 goto :EOF echo "No StreamBase Server found. Exiting." >&2 goto :EOF