Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8087

Профиль | Отправить PM | Цитировать


Цитата Burning Hell:
Iska, код приложил. »
В данном случае лучше делать сие так:

Скрытый текст
Код: Выделить весь код
:start
set day=%date:~0,2%
set month=%date:~3,2%
set year=%date:~6,4%

set /a hour=%time:~0,2%
if %hour% lss 12 (
	set format=AM) else (
	set format=PM)

If %hour% gtr 12 ( set /a hour = %hour% - 12 ) 
If %hour% == 00 ( set hour = 12 )

set /a minute=%time:~3,2%
set /a second=%time:~6,2%

set lasr_log_nm=check_va_lasr_status_%year%-%month%-%day%__%hour%.%minute%.%second% %format%.log

set full_log_path=D:\logs\%lasr_log_nm%

call D:\SAS\sas.exe -sysin D:\codes\check_va_lasr\check_va_lasr_status.sas -log "%full_log_path%"

set port=lasr_port
set host=lasr_host

call :get_params_from_main_config %port% %host% port host

type "%full_log_path%" | >nul 2>&1 findstr.exe /i /l /c:"error" /c:"connection" /c:"lasr" /c:"%port%" /c:"%host%" && set lasrError=true || set lasrError=false

echo lasrError=%lasrError%

if %lasrError%==true (
	call D:\SAS\sas.exe -sysin D:\codes\check_va_lasr\check_lasr_log_and_run.sas -nolog
	echo "Goto second iteration"
	goto :start
) else (
goto :EOF
)

rem =========================================================================
:get_params_from_main_config
@echo off
setlocal enableextensions enabledelayedexpansion

set sSourceFile=D:\codes\common\init_environment.sas

if exist "%sSourceFile%" (
	for /f "usebackq tokens=2,3 delims==; " %%i in (
		`type "%sSourceFile%" ^| findstr.exe /i /r /c:"%%let %1 = [0-9]*;"`
	) do set s%1=%%j

	if defined slasr_port (
		echo [!slasr_port!]
	) else (
		echo Not found [lasr_port]
	)

	for /f "usebackq tokens=2,3 delims==; " %%i in (
		`type "%sSourceFile%" ^| findstr.exe /i /r /c:"%%let %2 = .*;"`
	) do set s%2=%%j

	if defined slasr_host (
		echo [!slasr_host!]
	) else (
		echo Not found [slasr_host]
	)

) else (
	echo Can't find source file [%sSourceFile%].
	exit /b 1
)

endlocal & (set /a %3=%slasr_port% & set %4=%slasr_host%)
exit /b 0
rem =========================================================================

Отправлено: 08:45, 28-07-2017 | #38