使用 Popen 和 shell=False 执行 python 脚本
Execute a python script using Popen with shell=False
我想知道是否可以执行这个命令
cmd = "gnome-terminal -e 'python /path/to/file.py'"
p = subprocess.Popen(cmd,shell=True)
但是 shell=False
我试过运行这个命令
p = subprocess.Popen(["gnome-terminal","-e","python","/path/to/file.py"],shell = False)
但它不起作用:
谢谢!
您是将命令传递给 gnome-terminal
,而不是 python
。
p = subprocess.Popen(["gnome-terminal","-e","python /path/to/file.py"],shell = False)
我想知道是否可以执行这个命令
cmd = "gnome-terminal -e 'python /path/to/file.py'"
p = subprocess.Popen(cmd,shell=True)
但是 shell=False
我试过运行这个命令
p = subprocess.Popen(["gnome-terminal","-e","python","/path/to/file.py"],shell = False)
但它不起作用:
谢谢!
您是将命令传递给 gnome-terminal
,而不是 python
。
p = subprocess.Popen(["gnome-terminal","-e","python /path/to/file.py"],shell = False)