python远程连接服务器并查看服务器上的文件


import paramiko
from config.cfg import host, port, username, password

class ConLinux:

    def __init__(self):
        self.client = paramiko.SSHClient()
        self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self.client.connect(host, port, username, password)

    def get_client(self):
     # 注释的部分是查看文件
# ['root']['orders']['herb_medical_order']['herb_medical_order_info']['order_status'] # stdout = self.client.exec_command('cat /tmp/hisresult/2020-03-05/H0003/receive_path/{}*.txt'.format(filename))[1] # content = stdout.read() # print(xmltodict.parse(content.decode('utf-8'))) return self.client

源码:传送门


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM