使用python

时间:2018-12-26 15:56:57

标签: python bash

我需要从远程主机目录获取文件列表,并在本地计算机上运行代码。它类似于远程主机上的os.listdir(),而不是运行python代码的本地计算机中的os.lisdir()(因为我想从远程计算机中列出,因此此listdir会列出我的本地文件)。

在bash中,此命令有效ssh user@host "find /remote/path/ -name "pattern*" -mmin -15" > /local/path/last_files.txt使用python以某种方式适应before bash命令 os.system('ssh user@host ls /remote/path/ | tail -n10 > /local/path/last_files.txt),但必须读取文件/local/path/last_files.txt

在不使用bash初始化(aka,不使用os.system)的情况下,使用python在远程主机中是否可以执行ls(或一般而言,任何bash命令)形式?

我知道有一个名为paramiko的库,但我也想知道您是否知道其他替代方案(不知道是否还有其他更有效或更简便的替代方案)。

0 个答案:

没有答案
相关问题