通过pexpect获取集群主机信息


import pexpect

ip = 'xx'

cmd = 'xx'

ssh = pexpect.spawn('ssh %s  %s'  %(ip,cmd))

r = ssh.read()

print r