func Command(command string) (data string,err error){
var msg []byte
var cmd *exec.Cmd
cmd = exec.Command("sh","-c",command)
if msg, err = cmd.Output(); err != nil {
return "",err
}
return string(msg),nil
}
func Command(command string) (data string,err error){
var msg []byte
var cmd *exec.Cmd
cmd = exec.Command("sh","-c",command)
if msg, err = cmd.Output(); err != nil {
return "",err
}
return string(msg),nil
}
本文标题:Golang中执行shell
本文链接:https://www.haomeiwen.com/subject/qvsikktx.html
网友评论