Golang交互式执行adb命令

Golang交互式执行命令


func main(){
        in := bytes.NewBuffer(nil)
        cmd := exec.Command("adb.exe","shell")
        cmd.Stdin = in
        cmd.Stdout= os.Stdout
        go func() {
                in.WriteString("cd /data/local/tmp\n")
                in.WriteString("ls\n")
                in.WriteString("exit\n")
        }()
        if err := cmd.Run(); err != nil {
                fmt.Println(err)
                return
        }

}

你可能感兴趣的:(Go)