2016-11-16 52 views
-1

我有一個小的nslookup .cmd,它給了我更多的輸出。 我已經知道我正在查找的機器的名稱,以及DNS名稱,唯一需要的信息是機器地址。nslookup的輸出操作

@echo off 

set variable=1 

:start 
nslookup ***-%variable%.****** >> test.txt 
set /a variable=variable+1 

timeout /t 3 

if %variable% LSS *** goto start 

:next 

這是我在我的txt文件得到,如果使用nslookup沒有找到一臺機器:

服務器:**********

地址:

名稱:**** **** ****

地址:

但是,如果它沒有找到一個機器,我仍然得到:

服務器:**********

地址:

能輸出被操縱這樣一來,當它實際上找到一臺機器,只需要地址的一部分,它只是寫入.TXT?

回答

0

,如果你不介意的話,每臺服務器執行nslookup兩次(一次檢查,如果服務器存在,第二個得到輸出):

nslookup ***-%variable%.****** 2>nul|findstr /b "Name:">nul && nslookup ***-%variable%.****** >> test.txt