Guest User

Untitled

a guest
Jun 24th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import paramiko
  4. import sys
  5.  
  6.  
  7. def send_string_and_wait_for_string(command, wait_string, should_print):
  8. shell.send(command)
  9.  
  10. receive_buffer = ""
  11.  
  12. while not wait_string in receive_buffer:
  13. receive_buffer += shell.recv(1024)
  14.  
  15. if should_print:
  16. print receive_buffer
  17.  
  18. return receive_buffer
  19.  
  20. client = paramiko.SSHClient()
  21. client.load_system_host_keys()
  22. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  23. client.connect("10.62.62.10", username="testuser", password="testpasswd", look_for_keys=False, allow_agent=False)
  24.  
  25. shell = client.invoke_shell()
  26. send_string_and_wait_for_string("", "#", False)
  27. send_string_and_wait_for_string("terminal length 0\n", "#", False)
  28. output=send_string_and_wait_for_string("show logging\n", "#", False)
  29. print output
  30. client.close()
Add Comment
Please, Sign In to add comment