您的位置:首页 > 运维架构 > Linux

pexpect-pxssh-登陆Linux-执行命令

2015-11-30 14:48 447 查看
#!/usr/bin/python
import pexpect
import pxssh
try:
remote=pxssh.pxssh()
hostname=raw_input('hostname:')
username=raw_input('username:')
password=raw_input('password:')
remote.login(hostname,username,password)
remote.sendline('cd /opt/autotest/')
remote.prompt()
remote.sendline('ll')
remote.prompt()
print remote.before
print('成功了吧')
remote.logout()
except pxssh.ExceptionPxssh,e:
print'pxssh failed on login'
print str(e)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: