我想从Go执行perforce命令行“p4”来执行登录作业. “p4登录”要求用户输入密码.
如何在Go中运行需要用户输入的程序?
以下代码不起作用.
err = exec.Command(p4cmd,"login").Run() if err != nil { log.Fatal(err) }
来自
os/exec.Command文档:
// Stdin specifies the process's standard input. If Stdin is // nil,the process reads from the null device (os.DevNull). Stdin io.Reader
在执行命令之前设置命令的Stdin字段.