简体   繁体   中英

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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