- package main
- import (
- "fmt"
- "os/exec"
- )
- func main() {
- cmd := exec.Command("/bin/sh", "./exec.sh")
- bytes, err := cmd.Output()
- if err != nil {
- fmt.Println("cmd.Output: ", err)
- return
- }
- fmt.Println(string(bytes))
- }
- #该片段来自于http://www.codesnippet.cn/detail/290820135436.html
来源: http://www.codesnippet.cn/detail/290820135436.html