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

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

Пользователь


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

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


В скрипте какая-то ошибка:


Код: Выделить весь код
C:\>setlocal enableextensions enabledelayedexpansion

C:\>set sFileSource=C:\pc.txt

C:\>set sLog=C:\report.txt

C:\>if defined sFileSource (if defined sLog (if exist "C:\pc.txt" (copy nul "C:\report.txt" 1>nul for /F "usebackq tokens=*" %i in ("C:\pc.txt") 
do (
set sName= 
set sAddress= 
for /F "tokens=1,2* delims=,:   " %j in ('nslookup "%i" 2>&1 | findstr.exe /r /i /c:"Name:    " /c:"Address:  " /c:"\*\*\* "') 
do (if "%j" EQU "***" (set s%j=%k %l )  else (set s%j=%k ) )
 (if defined sName (echo !sName! = !sAddress! )  else (echo %i = !s***! ) ) 1>>"C:\report.txt"))  
	else (echo File with Names list [C:\pc.txt] not found ) )  else (call :Usage exit /b 1) )  else (call :Usage exit /b 1)





C:\>(
set sName= 
set sAddress= 
for /F "tokens=1,2* delims=,:   " %j in ('nslookup "PCNAME1" 2>&1 | findstr.exe /r /i /c:"Name:    " /c:"Address:  " /c:"\*\*\* "') do (if "%j" EQU "***" 
(set s%j=%k %l )  else (set s%j=%k ) )
(if defined sName (echo !sName! = !sAddress! )  else (echo PCNAME1 = !s***! )) 1>>"C:\report.txt")

C:\>(if "Address" EQU "***" (set sAddress=10.4.27.7  )  else (set sAddress=10.4.27.7 ) )

C:\>(if "Address" EQU "***" (set sAddress=10.1.92.228  ) else (set sAddress=10.1.92.228 ) )

C:\>(
set sName=
set sAddress=
for /F "tokens=1,2* delims=,:   " %j in ('nslookup "PCNAME2" 2>&1 | findstr.exe /r /i /c:"Name:    " /c:"Address:  " /c:"\*\*\* "') do (if "%j" EQU "***" 
(set s%j=%k %l )  else (set s%j=%k ) ) 
(if defined sName (echo !sName! = !sAddress! )  else (echo PCNAME2 = !s***! )) 1>>"C:\report.txt")

C:\>(if "Address" EQU "***" (set sAddress=10.4.27.7  )  else (set sAddress=10.4.27.7 ) )

C:\>(if "Address" EQU "***" (set sAddress=10.1.92.127  ) else (set sAddress=10.1.92.127 ) )

C:\>(
set sName=
set sAddress=
for /F "tokens=1,2* delims=,:   " %j in ('nslookup "PCNAME3" 2>&1 | findstr.exe /r /i /c:"Name:    " /c:"Address:  " /c:"\*\*\* "') do (if "%j" EQU "***"
(set s%j=%k %l )  else (set s%j=%k ) )
(if defined sName (echo !sName! = !sAddress! )  else (echo PCNAME3 = !s***! ) ) 1>>"C:\report.txt")

C:\>(if "***" EQU "***" (set s***=srv.domain.ru не удалось )  else (set s***=srv.domain.ru ) ) main

C:\>(if "Address" EQU "***" (set sAddress=10.4.27.7  )  else (set sAddress=10.4.27.7 ) )

C:\>(
set sName=
set sAddress=
for /F "tokens=1,2* delims=,:   " %j in ('nslookup "PCNAME4" 2>&1 | findstr.exe /r /i /c:"Name:    " /c:"Address:  " /c:"\*\*\* "') do (if "%j" EQU "***"
(set s%j=%k %l )  else (set s%j=%k ) )
(if defined sName (echo !sName! = !sAddress! )  else (echo PCNAME4 = !s***! ) ) 1>>"C:\report.txt")

C:\>(if "***" EQU "***" (set sAddress=10.4.27.7 )  else (set sAddress=10.4.27.7 ) ) 

C:\>(if "Address" EQU "***" (set sAddress=10.1.92.23  )  else (set sAddress=10.1.92.23 ) )
По факту:
У PCNAME1 ip адрес = 10.1.92.22
У PCNAME2 ip адрес = 10.1.92.127
У PCNAME3 ip адрес = не удалось
У PCNAME4 ip адрес = 10.1.92.23

В файле он записывает так:
PCNAME1 =
PCNAME2 =
PCNAME3 = srv.domain.ru *Ґ г¤*«®бм **©вЁ PCNAME3: Non-existent domain
PCNAME4 = srv.domain.ru *Ґ г¤*«®бм **©вЁ PCNAME4: Non-existent domain

Отправлено: 10:40, 06-10-2011 | #7