如何解决fork / exec。没有这样的文件或目录退出状态1?
exec.Command的函数签名为:
func Command(name string, args ...string) *Cmd
name
程序的名称在哪里args
,参数在哪里。试试这个:
cmd := exec.Command("./goreplay", "--input-file", gor_name, "--input-file-loop", "--output-http", ras_ip)
解决方法
我在Mac(darwin / amd64)上使用Go 1.10.2,并且遇到此错误。就是说没有这样的文件或目录。
这是我的代码,
func loop1(gor_name string,ras_ip string) {
var a string
var c string
a = search_path()
fmt.Printf("当前路径为",a)
fmt.Println(os.Chdir(a))
c = fmt.Sprintf("%s %s %s %s","./goreplay --input-file ",gor_name," --input-file-loop --output-http ",ras_ip)
fmt.Printf("c: ",c)
cmd := exec.Command(c)
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
channel <- 1
}
非常感谢您的任何建议。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。