python3 pexpect模块,python模块,pexpectimp


pexpect

import pexpectip="127.0.0.1"name="root"pwd="root"#发送命令执行交互  child=pexpect.spawn(‘ssh  %[email protected]%s‘ % ("root",ip)  )child.expect (‘password:‘)child.sendline(pwd)child.expect(‘$‘)child.sendline(‘df -h‘)#发送命令  child.sendline("exit")child.interact()#关闭pexpect  child.close()

python3 pexpect模块

评论关闭