Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fork/exec . no such file or directory exit status 1

Tags:

fork

go

exec

I am using Go 1.10.2 on Mac (darwin/amd64) and facing this error. It's saying no such file or directory.

Here's my code,

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

}

Thanks a lot for any suggestions.

like image 838
xiang tianyu Avatar asked May 11 '18 04:05

xiang tianyu


1 Answers

The function signature for exec.Command is:

func Command(name string, args ...string) *Cmd

where name is the name of the program and args are the arguments. Try this:

cmd := exec.Command("./goreplay", "--input-file", gor_name, "--input-file-loop", "--output-http", ras_ip)
like image 81
Bayta Darell Avatar answered Nov 07 '22 22:11

Bayta Darell