Go: fork/exec . no such file or directory
Problem:
When using Go 1.10.2 on macOS, you encounter the "no such file or directory" error with the following code:
cmd := exec.Command(c)
where c is a string containing the command to be executed.
Answer:
The error indicates that the specified command doesn't exist or cannot be found in the current directory. To resolve this, ensure that the executable file for the command is present in the current working directory or is available in the path environment variable.
Additionally, the signature of exec.Command has been updated since you may have encountered this error. The current signature is:
func Command(name string, args ...string) *Cmd
where name is the name of the program and args are the arguments to be passed to the program.
To resolve the issue, try modifying your code as follows:
cmd := exec.Command("./goreplay", "--input-file", gor_name, "--input-file-loop", "--output-http", ras_ip)
This should ensure that the "no such file or directory" error is resolved.
The above is the detailed content of Go exec.Command: Why 'no such file or directory'?. For more information, please follow other related articles on the PHP Chinese website!