Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def runBlockingCommands(*someCommands):
  2.     global testid, const_sshhost, const_sshuser, const_sshpass, const_prompt
  3.     ssh = paramiko.SSHClient()
  4.     ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  5.     ssh.connect(const_sshhost, username= const_sshuser, password= const_sshpass)
  6.     chan = ssh.invoke_shell()
  7.     for i in someCommands:
  8.         buff = ''
  9.         chan.send(i)
  10.         chan.send('\n')
  11.         logCustom('SSH WAIT COMMAND SENT', i)
  12.         while not buff.endswith(const_prompt):
  13.             resp = chan.recv(9999)
  14.             buff += resp
  15.         logCustom('SSH WAIT RESPONSE RECEIVED', i)
  16.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement