python 之pxssh“大变身”让它成为可交互小程序
2016-11-16 12:52
148 查看
需注意的问题: 1、pxssh类,存在于pexpect模块里,如果没有安装此模块请自行安装,如果已经存在此模块,但是没有pxssh类,经验证,那就是此模块的版本太低。请更新至新版本 #!/usr/bin/env python from pexpect import pxssh import os,getpass hosts = raw_input('Enter the host address:') username = raw_input('Enter the user name:') passwd = getpass.getpass('Enter the password:') shell = raw_input('Type the command:') try: s = pxssh.pxssh() s.login(hosts,username,passwd) s.sendline(shell) s.prompt() print s.before s.logout() except pxssh.ExceptionPxssh, e: print "pxssh failed on login" print str(e)
相关文章推荐
- 【python系列】Python启动外部程序,以及进程间交互
- 举例讲解Python程序与系统shell交互的方式
- 用eclipse写Python,当其交互式程序时交互方法
- 记录 python flask 与微信小程序交互
- 第一周作业——浏览python网站的发现与收获和如果我成为python高手,我想写的程序
- LINUX下非交互加入root权限用户和修改密码的python小程序
- python01 用户交互程序
- 人机交互程序 python实现人机对话
- 设置python 命令行交互程序自动补齐
- python3:使用paramiko交互小程序
- python 交互程序编写
- 在window7下,在pycharm中,编写python程序,和leapmotion交互
- Python程序的交互
- 基于tcp交互的python聊天程序
- os负责程序与操作系统的交互,sys负责程序与python解释器的交互。
- python-简单用户交互小程序
- 【HW】假设你已经成为一位Python编程高手,你打算实现什么样的程序?
- Python 用户交互程序Input
- Python学习笔记——字符编码与二进制,字符编码的区分和介绍和用的交互程序
- 02python程序和用户交互