标签:word style lin python3 pexpect close imp password import
pexpect
import pexpect ip="127.0.0.1" name="root" pwd="root" #发送命令执行交互 child=pexpect.spawn(‘ssh %s@%s‘ % ("root",ip) ) child.expect (‘password:‘) child.sendline(pwd) child.expect(‘$‘) child.sendline(‘df -h‘) #发送命令 child.sendline("exit") child.interact() #关闭pexpect child.close()
标签:word style lin python3 pexpect close imp password import
原文地址:https://www.cnblogs.com/fengzi7314/p/10218567.html