标签:info root send getpass roo 远程操作 操作 name exp
#!/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)
标签:info root send getpass roo 远程操作 操作 name exp
原文地址:https://www.cnblogs.com/mmdln/p/9050148.html