通过python,有没有办法打开gnome-terminal然后发送命令给它,然后在那个窗口中运行?例如,在哪里可以做类似Python - 与gnome-terminal进行通信
terminal.communicate("echo testing")
和gnome-terminal打印输出?我已经看到了使用子进程Popen并进行通信的类似帖子,虽然我没有得到新开放的终端来运行命令。感谢您的帮助
通过python,有没有办法打开gnome-terminal然后发送命令给它,然后在那个窗口中运行?例如,在哪里可以做类似Python - 与gnome-terminal进行通信
terminal.communicate("echo testing")
和gnome-terminal打印输出?我已经看到了使用子进程Popen并进行通信的类似帖子,虽然我没有得到新开放的终端来运行命令。感谢您的帮助
你可以做使用os.system来执行命令,像这样
import os
os.system("gnome-terminal -e 'bash -c \"sudo apt-get update; exec bash\"'")
这类似于[这个问题](http://askubuntu.com/questions/313554/how-to -control-gnome-terminal-from-python-scrypt),其中未答复。回答的问题似乎只在gnome终端开始时发送一个命令。 – Shatnerz
来自复本的答案已经处理它:创建一个命名管道并将命令写入它(有多少个)。 – jfs
我想我错过了一些东西。我无法让终端从命名管道运行命令 – Shatnerz