【发布时间】:2016-11-15 16:12:41
【问题描述】:
我正在创建一个 GUI 来简化 UNIX 中的一些任务。 我想在 UNIX 中通过终端启动一个进程。 我使用了
的模块subprocess.Popen()
启动进程。 问题是,当我启动该进程时,该进程要求用户输入他们的密码。 我正在考虑创建一个窗口来询问用户的密码。 如何将在窗口中输入的密码发送到终端中的进程启动?
代码如下:
password = wx.TextEntryDialog(None, "What is your password?", 'Password')
if password.ShowModal() == wx.ID_OK:
response = password.GetValue()
command = 'ssh -X pcalcul0 firefox http://qualnetsrv/intraqual//identification.aspx?ref=G0-1427'
user_manual = subprocess.Popen(command, universal_newlines=True,
stdin=response,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)
【问题讨论】:
标签: python wxpython subprocess