#!/usr/bin/python
import pexpect
import sys
sip="ssh root@172.10.224.183"
try:
child=pexpect.spawn(sip)
res = child.expect(['Are you sure you want to continue connecting (yes/no)?', 'password:'])
if res==0:
child.sendline('yes')
child.expect('password:')
child.sendline('123456')
child.expect('#')
child.sendline('ls -l')
child.sendline('df -h')
print child.before
child.sendline('exit')
child.interact()
except pexpect.EOF,pexpect.TIMEOUT:
print 'timeout...'

相关文章:

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