python Fabric : How to retrieve a filelist of a dir

标签 python file fabric dir filelist

我正在使用 python-fabric 库构建一个远程服务器管理工​​具,并且正在寻找一种检索远程服务器上目录的文件列表的好方法。目前我正在使用 run("ls dir") 并手动拆分返回字符串,这看起来很可怕并且非常依赖于体系结构。 fabric.contrib.files 似乎不包含任何有用的东西..

非常感谢您的建议。

干杯, R

最佳答案

这是怎么回事?

output = run('ls /path/to/files')
files = output.split()
print files

检查 documentation on run()更多技巧。

关于 python Fabric : How to retrieve a filelist of a dir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6628263/

相关文章:

java - 求java访问文件位置,如何学习记录的大小

python - pep8 因织物而失败

python - 在 django rest 框架中调用序列化器

python - 使用 super 用户 Django 1.9、Python 3.5 的凭据测试登录

python - 具有多个 models.py 的 Flask 应用程序的结构

python - 从 Python 脚本创建多 View Paraview 屏幕截图

linux - 搜索单词完成后显示文件内容

ruby-on-rails - 如何在rails中上传文件?

python - 为什么在尝试运行 fab 模块时出现语法错误?

Python Fabric : How to answer to keyboard input?