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