Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. from pexpect import pxssh
  2. import getpass
  3. file = 'log.txt'
  4. fp = open(file, 'w')
  5. try:
  6. s = pxssh.pxssh()
  7. hostname = raw_input('hostname: ')
  8. username = raw_input('username: ')
  9. password = getpass.getpass('password: ')
  10. s.login(hostname, username, password)
  11. s.sendline('network port show') # run a command
  12. s.prompt('cluster1::>') # match the prompt
  13. print(s.before) # print everything before the prompt.
  14. s.sendline('network interface show')
  15. s.prompt('cluster1::>')
  16. print(s.before)
  17. s.sendline('disk show')
  18. s.prompt('cluster1::>')
  19. print(s.before)
  20. s.logout()
  21. except pxssh.ExceptionPxssh as e:
  22. print("pxssh failed on login.")
  23. print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement