Имя пользователя:
Пароль:
 

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

Ветеран


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

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


HFShak, добрался до домена, посмотрел. Проблему подтверждаю.

Добавил принудительное обнуление переменной окружения «sError». Попробуйте теперь так:
читать дальше »
Код: Выделить весь код
@echo off
setlocal enableextensions enabledelayedexpansion

set sFileSource=%~1
set sLog=%~2

call :GetTemporaryName
set sStdOut=%TemporaryName%

call :GetTemporaryName
set sStdErr=%TemporaryName%

if defined sFileSource (
	if defined sLog (
		if exist "%sFileSource%" (
			>nul copy nul "%sLog%"
			
			for /f "usebackq tokens=*" %%i in ("%sFileSource%") do (
				echo Processing [%%i]...
				set sName=
				set sAddress=
				set sError=
				set bCriticalError=
				
				>nul copy nul "%sStdOut%"
				>nul copy nul "%sStdErr%"
				
				nslookup.exe "%%i" 1>"%sStdOut%" 2>"%sStdErr%"
				
				<"%sStdErr%" set /p sError=
				
				if defined sError (
					if "!sError:~0,3!" equ "***" (
						>>"%sLog%" echo %%i = !sError!
						set bCriticalError=1
					)
				)
				
				if not defined bCriticalError (
					set /a iCount = 0
					for /f "usebackq skip=3 tokens=2 delims=,:	 " %%j in ("%sStdOut%") do (
						set /a iCount += 1
						
						if !iCount! equ 1 set sName=%%j
						if !iCount! equ 2 set sAddress=%%j
					)
					>>"%sLog%" echo !sName! = !sAddress!
				)
			)
			
			if exist "%sStdOut%" del /f /q "%sStdOut%"
			if exist "%sStdErr%" del /f /q "%sStdErr%"
		) else (
			echo File with Names list [%sFileSource%] not found
		)
	) else (
		call :Usage
		exit /b 1
	)
) else (
	call :Usage
	exit /b 1
)

endlocal
exit /b 0
rem ==========================================================================

rem ==========================================================================
:Usage
	echo Usage: %~nx0 ^<Names list^> ^<Log file^>
	exit /b 0
rem ==========================================================================

rem ==========================================================================
rem Функция GetTemporaryName()
rem
rem Серый форум / CMD/BAT: генерация пути для временного файла или папки
rem (http://forum.script-coding.com/viewtopic.php?id=6259)
rem ==========================================================================
:GetTemporaryName
	setlocal enableextensions enabledelayedexpansion

:NextName
	set sTempName=%temp%\temp%random%.tmp

	if exist "%sTempName%" goto :NextName

	set sProcName=%~0

	endlocal & set %sProcName:~4%=%sTempName%
	exit /b 0
rem ==========================================================================
Это сообщение посчитали полезным следующие участники:

Отправлено: 12:04, 19-10-2011 | #15