如何设置Fabric任务的工作目录? [英] How to set the working directory for a Fabric task?

查看:102
本文介绍了如何设置Fabric任务的工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我定义了一个琐碎的任务来列出远程服务器上的文件:

Assuming I define a trivial task to list files on a remote server:

from fabric.api import run, env

env.use_ssh_config = True

def list_files():
    run('ls')

然后执行:

fab -H server list_files

除了执行以下操作外,如何为正在运行的命令指定工作目录:

How can I specify the working directory for the command I'm running, other than doing:

run('cd /tmp && ls')

对我来说,哪个看起来不太习惯?

Which doesn't look very idiomatic to me?

免责声明:这是我一生中第一次接触Fabric,对Python还是陌生的.

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆