从python脚本启动屏幕失败

时间:2018-09-06 23:29:11

标签: python python-3.x subprocess gnu-screen

我想打开一个屏幕并运行python脚本。我想借助python脚本来做到这一点

这就是我所做的

1。

self.my_cmd = "screen -d -m -S myscreenname /usr/bin/python3 
/opt/myscript.py"
subprocess.call(self.my_cmd)

self.my_cmd = "screen -d -m -S myscreenname /usr/bin/python3 
/opt/myscript.py"
subprocess.call(self.my_cmd,shell=True)

2。

self.my_cmd = ["screen", "-d", "-m", "-S", "myscreenname", "/usr/bin/python3", "/opt/myscript.py"]
subprocess.Popen(self.my_cmd) 

3。

self.my_cmd = ["screen", "-d", "-m", "-S", "myscreenname", "/usr/bin/python3", "/opt/myscript.py"]
subprocess.run(self.my_cmd) 

self.my_cmd = ["screen", "-d", "-m", "-S", "myscreenname", "/usr/bin/python3", "/opt/myscript.py"]
subprocess.run(self.my_cmd, shell=True)

self.my_cmd = "screen -d -m -S myscreenname /usr/bin/python3 /opt/myscript.py"
subprocess.run(self.my_cmd, shell=True)

某些命令会打开一个屏幕,但不执行脚本本身。

每个命令实际上都失败了。但是,如果我自己在shell中运行命令,那么:没问题...我在做什么错了?

0 个答案:

没有答案