我有一个python脚本,它需要打开另一个终端窗口来发送一些命令。Stackoverflowers已经让我走了那么远:
import subprocess
server_terminal = subprocess.Popen(['open','-a','/Applications/Utilities/Terminal.app','/Applications/Utilities/Terminal.app']) #Not sure about the inelegance of the doubled path, but it does open another terminal window, which I need.
下一步,我需要向这个终端发送一些命令,这样我就可以在用户的桌面上设置一个本地服务器。在计算如何控制此子进程时遇到一些重大问题。在
有人能告诉我如何让这个终端子进程从我这里拿走stdin吗?我宁愿避免第三方模块。在
{我的主要目标是在一个单独的窗口中编辑一个命令。我已经知道如何控制服务器一旦启动,我只是不知道如何自动启动一个。在
谢谢你的帮助!在
您可以使用
Popen
直接启动服务器:如果要查看输出,可以使用
^{pr2}$os.system
:相关问题 更多 >
编程相关推荐