简体   繁体   English

使用Shell = False的Popen执行python脚本

[英]Execute a python script using Popen with shell=False

I would like to know if it's possible to execute this command 我想知道是否可以执行此命令

cmd = "gnome-terminal -e 'python /path/to/file.py'"

p = subprocess.Popen(cmd,shell=True)

but with shell=False 但是shell = False

I tried to run this command 我试图运行此命令

p = subprocess.Popen(["gnome-terminal","-e","python","/path/to/file.py"],shell = False)

but it's not working: 但它不起作用:

Thank you! 谢谢!

因为它是将命令传递给gnome-terminal ,而不是python

p = subprocess.Popen(["gnome-terminal","-e","python /path/to/file.py"],shell = False)

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

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