无法使Fabric的分离屏幕会话示例正常工作

无法使Fabric的分离屏幕会话示例正常工作

本文介绍了无法使Fabric的分离屏幕会话示例正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用分离的屏幕会话在远程主机上执行脚本.我尝试了示例Fabric提供了,但不幸的是它无法正常工作.

I am trying to execute a script on a remote host using a detached screen session. I tried out the example Fabric gives and unfortunately couldn't get it to work.

from fabric.api import run

def yes():
    run('screen -d -m "yes"')

在我的本地计算机上执行fab yes可以正确地将其连接到远程主机,并说命令已经运行,但是在远程主机上什么也没有执行.在任何一台计算机上尝试screen -d -m "yes"都能按预期工作.

Executing fab yes on my local machine correctly connects it to the remote host and says the command has been run, however nothing is executed on the remote host. Trying screen -d -m "yes" on either machine works as expected.

如果有人能指出我在做什么错,我将不胜感激.另外,顺便说一句,为什么命令中的yes周围有引号?如果没有引号,是否可以使用?谢谢!

If anyone could point out what I'm doing wrong I'd greatly appreciate it. Also, on a side note, why are there quotes around the yes in the command? Would it work without the quotes? Thanks!

推荐答案

run('screen -d -m yes; sleep 1')可行.

虽然不确定是这种行为是织物还是屏幕造成的.

Not sure if Fabric or screen are to blame for this behaviour though.

这篇关于无法使Fabric的分离屏幕会话示例正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:17