2016-12-08 11:02
浏览 365

Go exec.Command()-运行包含管道的命令

The following works and prints the command output:

out, err := exec.Command("ps", "cax").Output()

but this one fails (with exit status 1):

out, err := exec.Command("ps", "cax | grep myapp").Output()

Any suggestions?

图片转代码服务由CSDN问答提供 功能建议

以下工作并打印命令输出:</ p>

  out  ,err:= exec.Command(“ ps”,“ cax”)。Output()
 </ code> </ pre> 

但这失败了(退出状态为1):</ p>

  out,err:= exec.Command(“ ps”,“ cax | grep myapp”)。Output()
 </ code> </ pre> 

有什么建议吗? </ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题