程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python SSH execution brush echo

編輯:Python

You need to make a ssh Brush command
class Mcu:
def init(self):
self.ssh_client = paramiko.SSHClient()
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
self.ssh_client.connect(hostname='', port=22, username='t', password='2')
print(' Successful connection ')

def WriteMcu_A(self): # stdin Command entered for  # stdout The result returned for the command  # stderr Is the result returned in case of command error  stdin, stdout, stderr = self.ssh_client.exec_command(' View version ') # cmd Carry out orders  result = stdout.read().decode('utf-8') # Read the execution result  print(result) self.version = re.findall("version::.+", result) print(self.version) print(" First step ") stdin, stdout, stderr = self.ssh_client.exec_command( Specified file ) result = stdout.read().decode('utf-8') # Read the execution result  print(result) print(" The second step ") stdin, stdout, stderr = self.ssh_client.exec_command(' Execute the command to start writing ') print(" The third step ") ## Here you need to show the progress of the brush ,percent == [100.00] and result == [0] The time brush is completed  #time.sleep(3000) results = stdout.read().decode('utf-8') print(results) # percent = re.findall("percent:n:.+", results) # result = re.findall(" result:n:.+", results) # print(percent,result) # if percent == [100.00]: # if result == [0]: stdin, stdout, stderr = self.ssh_client.exec_command(' Swipe complete ') result = stdout.read().decode('utf-8') # Read the execution result  print(result) print(" Step four ") self.ssh_client.close()

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved