我正在使用以下代码来获取nslookup命令的输出:
Dim oShell
Dim strCmdOutput
If DO_DEBUG="n" Then On Error Resume Next
Set oShell = WScript.CreateObject ("WScript.Shell")
Set shellOut = oShell.Exec("cmd.exe /C nslookup www.bbc.co.uk 8.8.8.8")
strCmdOutput = shellOut.StdOut.ReadAll()
WScript.Scho strCmdOutput
我进入strCmdOutput的输出与手动运行命令得到的输出不同。
例如,我手动获取:
Server: google-public-dns-a.google.com Address: 8.8.8.8 Non-authoritative answer: Name: www.bbc.net.uk Addresses: 212.58.244.71 212.58.246.95 Aliases: www.bbc.co.uk
使用我得到的脚本:
Server: google-public-dns-a.google.com Address: 8.8.8.8 Name: www.bbc.net.uk Addresses: 212.58.244.69 212.58.246.93 Aliases: www.bbc.co.uk
输出变化很大,有没有办法让输出匹配?
答案 0 :(得分:4)
行glide.yaml
写入STDERR,因此您需要将其合并到STDOUT以获取整个输出。
更改行
Non-authoritative answer:
到
Set shellOut = oShell.Exec("cmd.exe /C nslookup www.bbc.co.uk 8.8.8.8")
问题就会消失。