gpt4 book ai didi

python - 在远程执行 python fabric 命令之前总是给出命令行

转载 作者:行者123 更新时间:2023-12-04 19:03:44 25 4
gpt4 key购买 nike

我刚刚开始使用 python fabric 在远程 rackspace ubuntu 服务器上运行命令。如果没有需要我输入的命令行,我就无法运行命令。这是我如何重现问题的顺序。

使用 ssh 使用 key 和无密码连接到远程计算机没有任何问题。

这是我的 fabfile.py

from fabric.api import env, run

env.hosts = ['remote.ip.address']
env.user = 'http'

def hello():
run("touch hello.world")

我用来运行 fabfile.py 的命令(使用 python 2.7 virtualenv)
$ ~/env/py27/bin/fab -f code/fabfile.py hello

这是显示它如何总是卡住并要求我键入 exit 的命令行。
[remote.ip.address] Executing task 'hello'
[remote.ip.address] run: touch hello.world
[remote.ip.address] out: http@server-name:~$

我可以通过输入 exit 退出远程终端,命令将运行,我将返回到本地终端。
[remote.ip.address] out: exit
[remote.ip.address] out:

Done.
Disconnecting from remote.ip.address... done.
me@local-computer: $

这是我用来设置不需要密码的 ssh key 的方法。 https://kb.mediatemple.net/questions/1626/Using+SSH+keys+on+your+server

最佳答案

有趣,我没有这样的问题,你的代码对我来说很好(直到添加 env.key_filenameenv.password )

c:\work>fab hello
[x.x.x.x] Executing task 'hello'
[x.x.x.x] run: touch hello.world

Done.
Disconnecting from x.x.x.x... done.

我正在使用 Fabric 1.7.0 和 Paramiko 1.11.0。
可能是您服务器上的终端问题。

关于python - 在远程执行 python fabric 命令之前总是给出命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18775943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com