简体   繁体   English

Python:在Linux上启动新终端并等待它完成/退出

[英]Python: Start new terminal on Linux and wait for it to finish/exit

Same situation as my other question: Python: Start new command prompt on Windows and wait for it finish/exit except that I need it to work on Linux. 与我的另一个问题相同的情况: Python:在Windows上启动新的命令提示符并等待它完成/退出,除了我需要它在Linux上工作。

If you don't feel like reading the other question: I want to open some new terminal windows and have each execute a command, and I want the parent python program to wait until all the terminal windows are closed. 如果你不想阅读另一个问题:我想打开一些新的终端窗口并让每个执行一个命令,我希望父python程序等到所有终端窗口关闭。

Doing: 这样做:

os.system("gnome-terminal -e {command}")

Opens a new terminal window but the program doesn't wait. 打开一个新的终端窗口,但程序不会等待。 Using p = Popen() and p.wait() doesn't work because the gnome-terminal command completes instantly. 使用p = Popen() p.wait() p = Popen()p.wait()不起作用,因为gnome-terminal命令立即完成。

Gnome-terminal reuses the same parent process for all terminal windows. Gnome终端为所有终端窗口重用相同的父进程。

Use gnome-terminal --disable-factory to force it to start a new process. 使用gnome-terminal --disable-factory强制它启动一个新进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM