pexpect的pxssh类实现远程操作

#!/usr/bin/python
import pexpect
from pexpect import pxssh

import getpass
try:
s=pxssh.pxssh()
hostname='172.10.224.183'
username='root'
password='123456'
s.login(hostname,username,password)
s.sendline('uptime')
s.prompt()
print s.before
s.sendline('ls -l')
s.prompt()
print s.before
s.sendline('df -h')
s.prompt()
print s.before
s.logout()
except pxssh.ExceptionPxssh,e:
print "pxssh failed on login."
print str(e)

pexpect的pxssh类实现远程操作

 

相关文章:

  • 2021-12-19
  • 2021-08-28
  • 2021-10-04
  • 2021-11-18
  • 2021-12-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-06
  • 2021-12-09
  • 2022-12-23
  • 2021-11-09
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案