Issue 401: added CR to windows cmd files

This commit is contained in:
Adrian Cole 2010-11-11 10:47:16 +01:00
parent 5a177e9c76
commit 5b40df46c9
4 changed files with 189 additions and 189 deletions

View File

@ -1,3 +1,3 @@
echo log_level :info>>c:\etc\chef\client.rb echo log_level :info>>c:\etc\chef\client.rb
echo log_location STDOUT>>c:\etc\chef\client.rb echo log_location STDOUT>>c:\etc\chef\client.rb
echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb echo chef_server_url "http://localhost:4000">>c:\etc\chef\client.rb

View File

@ -1,134 +1,134 @@
@echo off @echo off
set PATH= set PATH=
set JAVA_HOME= set JAVA_HOME=
set PATH= set PATH=
GOTO FUNCTION_END GOTO FUNCTION_END
:abort :abort
echo aborting: %EXCEPTION% echo aborting: %EXCEPTION%
exit /b 1 exit /b 1
:default :default
set INSTANCE_NAME=mkebsboot set INSTANCE_NAME=mkebsboot
set INSTANCE_HOME=/mnt/tmp set INSTANCE_HOME=/mnt/tmp
set LOG_DIR=/mnt/tmp set LOG_DIR=/mnt/tmp
exit /b 0 exit /b 0
:mkebsboot :mkebsboot
set TMP_DIR=/mnt/tmp set TMP_DIR=/mnt/tmp
exit /b 0 exit /b 0
:findPid :findPid
set FOUND_PID= set FOUND_PID=
set _expression=%1 set _expression=%1
shift shift
set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH set FIND_PROCESS=TASKLIST /FI "WINDOWTITLE eq %_expression%" /NH
FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO ( FOR /F "usebackq tokens=2 delims= " %%A IN (`cmd /c "%FIND_PROCESS% 2>NUL"`) DO (
SET FOUND_PID=%%A SET FOUND_PID=%%A
) )
if defined FOUND_PID ( if defined FOUND_PID (
exit /b 0 exit /b 0
) else ( ) else (
set EXCEPTION=%_expression% not found set EXCEPTION=%_expression% not found
exit /b 1 exit /b 1
) )
:forget :forget
SETLOCAL SETLOCAL
set FOUND_PID= set FOUND_PID=
set NEXT_MINUTE= set NEXT_MINUTE=
set INSTANCE_NAME=%1 set INSTANCE_NAME=%1
shift shift
set SCRIPT=%1 set SCRIPT=%1
shift shift
set LOG_DIR=%1 set LOG_DIR=%1
shift shift
CALL :findProcess %INSTANCE_NAME% CALL :findProcess %INSTANCE_NAME%
if defined FOUND_PID ( if defined FOUND_PID (
echo %INSTANCE_NAME% already running pid [%FOUND_PID%] echo %INSTANCE_NAME% already running pid [%FOUND_PID%]
) else ( ) else (
CALL :nextMinute CALL :nextMinute
set _DATE=%DATE:~4% set _DATE=%DATE:~4%
set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE% set CMD=schtasks /create /sd %_DATE% /tn %INSTANCE_NAME% /ru System /tr "cmd /c title %INSTANCE_NAME%&%SCRIPT% >%LOG_DIR%\stdout.log 2>%LOG_DIR%\stderr.log" /sc:once /st %NEXT_MINUTE%
echo %INSTANCE_NAME% will start at %NEXT_MINUTE% echo %INSTANCE_NAME% will start at %NEXT_MINUTE%
set SECONDS=%TIME:~6,2% set SECONDS=%TIME:~6,2%
set /a SECOND=60-SECONDS set /a SECOND=60-SECONDS
%CMD% >NUL %CMD% >NUL
ping -n %SECONDS% 127.0.0.1 > NUL 2>&1 ping -n %SECONDS% 127.0.0.1 > NUL 2>&1
CALL :findProcess %INSTANCE_NAME% CALL :findProcess %INSTANCE_NAME%
if not defined FOUND_PID ( if not defined FOUND_PID (
set EXCEPTION=%INSTANCE_NAME% did not start set EXCEPTION=%INSTANCE_NAME% did not start
abort abort
) )
) )
exit /b 0 exit /b 0
:FUNCTION_END :FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" ( if not "%1" == "init" if not "%1" == "status" if not "%1" == "stop" if not "%1" == "start" if not "%1" == "tail" if not "%1" == "tailerr" if not "%1" == "run" (
set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run set EXCEPTION=bad argument: %1 not in init status stop start tail tailerr run
goto abort goto abort
) )
goto CASE_%1 goto CASE_%1
:CASE_init :CASE_init
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
call :mkebsboot call :mkebsboot
if errorlevel 1 goto abort if errorlevel 1 goto abort
md %INSTANCE_HOME% md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
md %INSTANCE_HOME% md %INSTANCE_HOME%
del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL del %INSTANCE_HOME%\mkebsboot.cmd 2>NUL
echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd echo @echo off>>%INSTANCE_HOME%\mkebsboot.cmd
echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd echo title mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_NAME=mkebsboot>>%INSTANCE_HOME%\mkebsboot.cmd
echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd echo set TMP_DIR=%TMP_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_NAME=%INSTANCE_NAME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd echo set INSTANCE_HOME=%INSTANCE_HOME%>>%INSTANCE_HOME%\mkebsboot.cmd
echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd echo set LOG_DIR=%LOG_DIR%>>%INSTANCE_HOME%\mkebsboot.cmd
echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd echo cd /d %%INSTANCE_HOME%%>>%INSTANCE_HOME%\mkebsboot.cmd
echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd echo exit /b 0 >>%INSTANCE_HOME%\mkebsboot.cmd
GOTO END_SWITCH GOTO END_SWITCH
:CASE_status :CASE_status
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME% call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort if errorlevel 1 goto abort
echo [%FOUND_PID%] echo [%FOUND_PID%]
GOTO END_SWITCH GOTO END_SWITCH
:CASE_stop :CASE_stop
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
call :findPid %INSTANCE_NAME% call :findPid %INSTANCE_NAME%
if errorlevel 1 goto abort if errorlevel 1 goto abort
if defined FOUND_PID ( if defined FOUND_PID (
TASKKILL /F /T /PID %FOUND_PID% >NUL TASKKILL /F /T /PID %FOUND_PID% >NUL
) )
GOTO END_SWITCH GOTO END_SWITCH
:CASE_start :CASE_start
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR% call :forget %INSTANCE_NAME% %INSTANCE_HOME%\%INSTANCE_NAME%.cmd %LOG_DIR%
if errorlevel 1 goto abort if errorlevel 1 goto abort
GOTO END_SWITCH GOTO END_SWITCH
:CASE_tail :CASE_tail
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
tail %LOG_DIR%\stdout.log tail %LOG_DIR%\stdout.log
GOTO END_SWITCH GOTO END_SWITCH
:CASE_tailerr :CASE_tailerr
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
tail %LOG_DIR%\stderr.log tail %LOG_DIR%\stderr.log
GOTO END_SWITCH GOTO END_SWITCH
:CASE_run :CASE_run
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
%INSTANCE_HOME%\%INSTANCE_NAME%.cmd %INSTANCE_HOME%\%INSTANCE_NAME%.cmd
GOTO END_SWITCH GOTO END_SWITCH
:END_SWITCH :END_SWITCH
exit /b 0 exit /b 0

View File

@ -1,17 +1,17 @@
md %TEMP%\%USERNAME%\scripttest md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
md %TEMP%\%USERNAME%\scripttest md %TEMP%\%USERNAME%\scripttest
del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL del %TEMP%\%USERNAME%\scripttest\yahooprod.cmd 2>NUL
echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo @echo off>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo title yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set INSTANCE_NAME=yahooprod>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo set JAVA_HOME=%JAVA_HOME%>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo cd /d %TEMP%\%USERNAME%\scripttest>>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd
echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd echo exit /b 0 >>%TEMP%\%USERNAME%\scripttest\yahooprod.cmd

View File

@ -1,35 +1,35 @@
@echo off @echo off
set PATH= set PATH=
set JAVA_HOME= set JAVA_HOME=
set PATH= set PATH=
set RUNTIME= set RUNTIME=
GOTO FUNCTION_END GOTO FUNCTION_END
:abort :abort
echo aborting: %EXCEPTION% echo aborting: %EXCEPTION%
exit /b 1 exit /b 1
:default :default
set RUNTIME=Moo set RUNTIME=Moo
exit /b 0 exit /b 0
:FUNCTION_END :FUNCTION_END
set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem set PATH=c:\windows\;C:\windows\system32;c:\windows\system32\wbem
if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" ( if not "%1" == "start" if not "%1" == "stop" if not "%1" == "status" (
set EXCEPTION=bad argument: %1 not in start stop status set EXCEPTION=bad argument: %1 not in start stop status
goto abort goto abort
) )
goto CASE_%1 goto CASE_%1
:CASE_start :CASE_start
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
echo start %RUNTIME% echo start %RUNTIME%
GOTO END_SWITCH GOTO END_SWITCH
:CASE_stop :CASE_stop
call :default call :default
if errorlevel 1 goto abort if errorlevel 1 goto abort
echo stop %RUNTIME% echo stop %RUNTIME%
GOTO END_SWITCH GOTO END_SWITCH
:CASE_status :CASE_status
echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt echo hello world>>%TEMP%\%USERNAME%\scripttest\temp.txt
echo the following should be []: [%RUNTIME%] echo the following should be []: [%RUNTIME%]
GOTO END_SWITCH GOTO END_SWITCH
:END_SWITCH :END_SWITCH
exit /b 0 exit /b 0