【发布时间】:2015-03-02 03:23:57
【问题描述】:
如何从我的 Go 程序执行 bash 脚本?这是我的代码:
目录结构:
/hello/
public/
js/
hello.js
templates
hello.html
hello.go
hello.sh
你好.go
cmd, err := exec.Command("/bin/sh", "hello.sh")
if err != nil {
fmt.Println(err)
}
当我运行 hello.go 并调用相关路由时,我会在控制台上看到这个:
exit status 127
output is
我期待 ["a", "b", "c"]
我知道在 SO:Executing a Bash Script from Golang 上有一个类似的问题,但是,我不确定我的路径是否正确。将不胜感激!
【问题讨论】: