golang 怎么使用管道执行windows命令
需要在windows下执行这个命令,
netstat -an |find /c "8888"
这样写不行的,还有办法吗?谢谢
if c, err = exec.Command("cmd", "/c", "netstat -an", "|", "find", "/c", "8888").CombinedOutput(); err != nil {
log.Fatal(err)
}
需要在windows下执行这个命令,
netstat -an |find /c "8888"
这样写不行的,还有办法吗?谢谢
if c, err = exec.Command("cmd", "/c", "netstat -an", "|", "find", "/c", "8888").CombinedOutput(); err != nil {
log.Fatal(err)
}
共 1 个回复
thewinds
分两次执行,或者写个pipeline链式操作,这个也不错
https://github.com/bitfield/script