【问题标题】:How do I permanently change directory using Fabric?如何使用 Fabric 永久更改目录?
【发布时间】:2015-05-17 09:49:03
【问题描述】:

这是我的代码。想法是切换到我也有符号链接的目录“Aquantia”,将字符串回显到文本文件中,然后将 Hello World 程序的输出重定向到文本文件中。如果我在实际的 Aquantia 目录中运行 fabfile.py,它可以工作,但是当我从 Home 启动时,它会失败。

from fabric.api import local, settings, abort, run, cd

def run():
    with cd('~/Aquantia'):
        local("echo 'love' > test.txt ")
        local("less test.txt")
        local("./test>test.txt")
        local("less test.txt")

这是错误信息:

DN0a152ee4:~ bmassoumi$ fab run
[localhost] local: echo 'love' > test.txt 
[localhost] local: less test.txt
[localhost] local: ./test>test.txt
/bin/sh: ./test: No such file or directory

Fatal error: local() encountered an error (return code 127) while executing './test>test.txt'

Aborting.
local() encountered an error (return code 127) while executing './test>test.txt'

【问题讨论】:

    标签: python python-2.7 terminal fabric


    【解决方案1】:

    来自fabric documentation

    cd 仅影响远程路径 - 要修改本地路径,请使用 lcd

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-27
      • 1970-01-01
      • 2011-02-27
      • 2018-02-05
      • 2018-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多