【发布时间】:2021-05-24 00:16:04
【问题描述】:
我想对 IP 列表进行 whois 查找,然后查找 grep country。
我有:
const { spawn } = require('child_process')
const ip_list = [
'192.168.1.1',
'192.168.1.2',
'192.168.1.3'
]
const process = spawn('whois', ip_list)
process.stdout.on('data', (data) => {
console.log(data)
})
相当于运行whois ip1 ip2 ip3 ...
但我想要相当于运行whois ip1 ip2 ip3 ... | grep country
如何在 Node 中做到这一点?
我尝试在 ip_list 末尾添加“| grep country”或只是“grep country”作为参数,但这给了我一个查询错误。
【问题讨论】:
-
不,如果我在 ip_list 末尾添加“grep country”或“| grep country”,我会收到错误“Invalid query ...”
标签: node.js