【问题标题】:problems with nslookup commandsnslookup 命令的问题
【发布时间】:2019-06-26 07:26:13
【问题描述】:

我需要编写一个脚本来自动化这个手动输入的过程:

nslookup
> server ns1.server.com
> ls example.com

我需要将 ls 的所有输出保存在 txt 或 csv 中。

事实是,我找不到任何方法可以将这 3 个步骤合二为一。而且我已经在 powershell、bash 上尝试了所有东西……但什么也没有。由于服务器无法访问 Internet 以下载相应的库,因此我无法使用 python 或其他语言进行测试。

我想用这个表单 nslookup ls example.com ns1.server.com> example.txt 做点什么

但是没有办法,请帮帮我。

最好的问候

【问题讨论】:

  • 因此您可以使用发送键或使用睡眠,然后在交互式自动化中发送您的第二个值。但这从来都不是一个好方法。您可以做的是直接调用nslookup ns1.server.com,这将有助于直接产生结果,并通过输入重定向(>>)或通过管道将输出重定向到文件| Out-File。但是一个单一的解决方案就是重定向nslookup >> Filepath\filename.txt,如果你看到控制台被暂停使用nslookup exit >> filepath\filename.txt的技巧。

标签: powershell nslookup


【解决方案1】:
Resolve-DnsName example.com -Server ns1.server.com  -Type ALL | Out-File -FilePath example.txt

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-07-18
  • 1970-01-01
  • 1970-01-01
  • 2018-05-12
  • 2010-09-24
  • 2020-07-23
  • 2013-12-17
  • 2021-04-27
相关资源
最近更新 更多