【问题标题】:How to make Fabric use the bash shell insread of the default shell?如何让 Fabric 使用 bash shell 而不是默认 shell?
【发布时间】:2021-05-31 20:20:55
【问题描述】:

我正在尝试使用 Fabric (Python3)。我的删除服务器使用“ksh”外壳,但我需要使用“bash”外壳。如何使用 Fabric 实现这一目标?

【问题讨论】:

    标签: python python-3.x bash ssh fabric


    【解决方案1】:

    我使用名为FABRIC_RUN_SHELL 的环境变量来执行此操作。例如:

    export FABRIC_RUN_SHELL=/usr/bin/bash
    

    你也可以直接在你的 fabfile.py 中配置:

    @task
    def my_task(c):
        pass
    
    @task
    def my_task2(c):
        pass
    
    ns = Collection(my_task)
    ns.configure({'run': {'shell': '/usr/bin/bash'}})
    

    还有其他选项,例如从配置文件加载。令人困惑的是,所有细节都在 Invoke configuration docs 中,而不是 Fabric 文档中。 Fabric configuration docs 中提到了您使用 FABRIC_ 前缀而不是 INVOKE_ 的事实。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多