First I thought that the issue was caused because the code did not reside in ~/go/src/<bitbucket.org>/<username>/
, but it turns out that it will also run successful if it is executed from the home directory, i.e. ~/
. Probably, like already was mentioned in the comments, the commands pwd
and ls
were not in the path or the program was executed as another user.
在$ PATH中找不到Unix可执行文件
I have a problem when using Go. Here is my code:
package main
import (
"fmt"
"os/exec"
)
func main() {
output, err := exec.Command("pwd").Output()
fmt.Println(string(output), err)
output, err = exec.Command("ls", "-l").Output()
fmt.Println(string(output), err)
}
When I run this, I get the following errors.
err exec: "pwd": executable file not found in $PATH;
err exec: "ls": executable file not found in $PATH
I'm using Ubuntu 14.04
.
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答
1条回答
为你推荐
- 在$ PATH中找不到Unix可执行文件
- ubuntu
- ls
- pwd
- 1个回答