2019-05-23 10:48
浏览 487


In my shell, I can exec command --issue --dns -d --yes-I-know-dns-manual-mode-enough-go-ahead-please and get output.

now I want to do that in go, and my code like:

cmd := exec.Command("bash", "-c", " --issue --dns -d --yes-I-know-dns-manual-mode-enough-go-ahead-please");
out, err := cmd.CombinedOutput()
if err != nil {
    log.Fatalf("issue failed with error: %s
", err)
fmt.Printf("combined out:
", string(out))

but I got error exit status 1.

and as the comment said, I separate argument:

exec.Command("bash", "-c", "", "--issue", "--dns", "-d", "--yes-I-know-dns-manual-mode-enough-go-ahead-please");

but the result is that it exec without parameters.

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

在我的shell中,我可以执行命令 --issue --dns -d exmaple。 com-是的,我知道dns-manual-mode-足够前进了并获取输出。

现在我想继续进行操作, 和我的代码一样:

  cmd:= exec.Command(“ bash”,“-c”,“ --issue --dns -d  --yes-I-nnow-dns-manual-mode-go-a-ahead-please“); 
out,err:= cmd.CombinedOutput()
if err!= nil {
 log.Fatalf(” issue 失败并出现错误:%s 
fmt.Printf(” combined out:
 \  n 



exec.Command(“ bash”,“-c”,“”,“-issue”,“-dns”,“-d”,“-是-I- 知道dns-manual-mode-足够前进了,请“);

,但是结果是它执行了 没有参数。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题