Guest User

Untitled

a guest
Oct 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import pexpect
  2. from pexpect import pxssh
  3. from time import sleep
  4.  
  5. m_localhost ='########'
  6. username='######'
  7. password='###########'
  8.  
  9. try:
  10. try:
  11. child=pexpect.spawn('ssh %s@%s' %(username,m_localhost))
  12. #if verbose:
  13. # child.logfile=sys.stdout
  14. #child.timeout=5
  15. child.expect('User: ')
  16. child.sendline(username)
  17.  
  18.  
  19. child.expect('Password:')
  20.  
  21. except Exception as e:
  22. print(e)
  23.  
  24. child.sendline(password)
  25. print("PASSWORD SENTTTTTTT")
  26. child.expect('>')
  27. #sleep(0.1)
  28. #print("Expecting a command for Cisco")
  29. child.sendline('config paging disablen')
  30. print('Disabled')
  31. child.expect('>')
  32.  
  33. alldata=child.sendline('show ap summary')
  34. #print(child.after)
  35.  
  36.  
  37.  
  38.  
  39. except Exception as e:
  40. print(e)
  41. print("IN")
  42.  
  43. print('---------')
  44. print(alldata)
Add Comment
Please, Sign In to add comment