Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pexpect import pxssh
- import getpass
- file = 'log.txt'
- fp = open(file, 'w')
- try:
- s = pxssh.pxssh()
- hostname = raw_input('hostname: ')
- username = raw_input('username: ')
- password = getpass.getpass('password: ')
- s.login(hostname, username, password)
- s.sendline('network port show') # run a command
- s.prompt('cluster1::>') # match the prompt
- print(s.before) # print everything before the prompt.
- s.sendline('network interface show')
- s.prompt('cluster1::>')
- print(s.before)
- s.sendline('disk show')
- s.prompt('cluster1::>')
- print(s.before)
- s.logout()
- except pxssh.ExceptionPxssh as e:
- print("pxssh failed on login.")
- print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement