【发布时间】:2019-06-08 02:42:43
【问题描述】:
在 Windows 系统上,我正在尝试收集 DNS 名称的所有 IP 地址并使用每个 IP 地址调用一个工具。我知道如何从 shell 脚本中执行此操作 - 但不知道如何从批处理或 powershell 文件中执行此操作。
我想把它移植到 Windows..
#!/usr/bin/env bash
# Get all the IPs for our server instance
# and pass it to "p4 trust" to update the .p4trust file
for address in $(dig perforce.example.com +short)
do
echo "processing address: $address:1666"
p4 -p "ssl:$address:1666" trust -y -f || true
done
问题:
- 是否有预安装的 Windows
dig等效项,仅返回 DNS 记录的 IP? - 在批处理或 powershell 文件中,如何迭代来自另一个应用程序的多个结果?
【问题讨论】:
-
foreach 在 powershell 中。你有 nslookup 和 resolve-dnsname。不要使用批处理。毕竟是 2019 年。
标签: windows powershell perforce dig