【问题标题】:Output manipulation for nslookupnslookup 的输出操作
【发布时间】:2016-11-16 15:18:08
【问题描述】:

我有一个小的 nslookup .cmd,它给了我比需要更多的输出。 我已经知道我要查找的机器的名称以及 DNS 名称,我需要的唯一信息就是机器地址。

@echo off

set variable=1

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

timeout /t 3

if %variable% LSS *** goto start

:next

如果 nslookup 确实找到了一台机器,这就是我在 .txt 文件中得到的内容:

服务器:**********

地址:...

名称:****.****.****

地址:...

但如果它没有找到机器我仍然得到:

服务器:**********

地址:...

是否可以这样操作输出,使其仅在实际找到机器时才写入 .txt 并且仅获取地址部分?

【问题讨论】:

    标签: cmd output nslookup


    【解决方案1】:

    如果您不介意每台服务器执行两次nslookup(一次检查,如果服务器存在,第二次获取输出):

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 2011-05-13
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-07
      相关资源
      最近更新 更多