完全独立于脚本运行命令 [英] Running a command completely indepenently from script
问题描述
最近,我遇到了一些情况,我想完全独立地启动命令,然后在与脚本不同的过程中,等效地将其键入终端,或更具体地说将命令编写为.sh或.desktop,双击它.我的要求是:
I have recently come across some situations where I want to start a command completely independently, and in a different process then the script, equivalent typing it into a terminal, or more specifically writing the command into a .sh or .desktop and double clicking it. The request I have are:
- 我可以关闭python窗口而无需关闭应用程序.
- python窗口不显示应用程序中的标准输出(您不希望CLI中出现随机文本),也不需要它!
我尝试过的事情:
- os.system等待.
- subprocess.call等待.
- subprocess.Popen启动一个子进程(duh),关闭父进程,从而退出应用程序
基本上,这就是您可以在网上找到的所有内容!如果确实如此,我可以启动.sh(或Windows的.bat),但这听起来像是廉价的骇客,而不是这样做的方法.
And thats basically all you can find on the web! if it really comes down to it I could launch a .sh (or .bat for windows), but that feels like a cheap hack and not the way to do this.
推荐答案
如果要放置&从os.system调用命令后,那行不通吗?例如:
If you were to place an & after the command when called from os.system, would that not work? For example:
import os
os.system( "google-chrome & disown " )
这篇关于完全独立于脚本运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!