我想在 golang 程序中运行一个交互式 shell 脚本,比如包装一个“ping 8.8.8.8”、“python”、“bc”、“mysql -H -P -u -p”。当 golang 程序完成调用交互式命令或 shell 并让生成的用户与用户交互时,应该退出。


我已经尝试过“exec.Command(“python”).Run()”,但是 golang 程序刚刚完成,什么都没有给我留下。


func (h ConnectHandler)ConnectMySQL()  {

    logrus.Debug("ConnectMySQL, script:",common.CONF.FilePath.MySQLConnectScriptPath)

    err :=exec.Command("bash",common.CONF.FilePath.MySQLConnectScriptPath).Run()

    if err != nil{

        logrus.Errorf("ConnectMySQL failed, exit 1,%s",err)

        os.Exit(1)

    }

}