[英]Open two own terminals, which run two scripts and wait for them to finish
I have a script which amongst others, gives the option to run an process . 我有一个脚本,其中有一个脚本,可以让您选择运行一个进程 。 I'm not talking about one executable, but about two python scripts which need to be run in an own terminal and produce output in the terminal.
我不是在谈论一个可执行文件,而是在两个Python脚本,它们需要在自己的终端中运行并在终端中产生输出。
I've considered script1 = subprocess.call(["/dir/python","/dir/script1","param"])
, or the same with /bin/bash
but this seems to run the python/bash the in the current terminal - not as an own window. 我已经考虑过
script1 = subprocess.call(["/dir/python","/dir/script1","param"])
,或与/bin/bash
相同,但这似乎在python / bash中运行当前终端-不作为自己的窗口。
If I'd do script1 = subprocess.call(["/usr/bin/xterm","param to run bash and my script"])
, a new window opens, but then the described problem below applies. 如果我要执行
script1 = subprocess.call(["/usr/bin/xterm","param to run bash and my script"])
,则会打开一个新窗口,但是下面描述的问题适用。
The other conceptual problem I have is, that I need to wait for both scripts. 我遇到的另一个概念性问题是,我需要等待两个脚本。 So if calling the subprocess would work, it'd wait when the first is called until it's done, then start the second, but they need to run simultaneously.
因此,如果调用子进程可以工作,则它将等待第一个被调用,直到完成为止,然后启动第二个,但它们需要同时运行。
How do I start two new terminals, each starting a specified script? 如何启动两个新的终端,每个终端都启动一个指定的脚本?
To run commands and wait for them to finish you run them in the background and then use the shell wait
built-in to tell the shell to wait for background jobs to finish. 要运行命令并等待它们完成,请在后台运行它们,然后使用内置的shell
wait
命令告诉Shell等待后台作业完成。
job1 &
job2 &
wait
For controlling the size of the log file see this question and my answer for ways of doing that with applications that behave and ones that don't. 要控制日志文件的大小,请参阅此问题和我的回答 ,以了解行为正常的应用程序和行为异常的应用程序的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.