python实现telnet客户端的方法
2015-04-15 09:12
736 查看
本文实例讲述了python实现telnet客户端的方法。分享给大家供大家参考。具体如下:
python实现的telnet客户端程序,python自带一个telnetlib模块,可以通过其Telnet类实现telnet操作
import getpass import sys import telnetlib HOST = "hostname" user = raw_input("Enter your remote account:") password = getpass.getpass() tn = telnetlib.Telnet(HOST) tn.read_until("login: ") tn.write(user + "\n") if password: tn.read_until("Password: ") tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") print tn.read_all()
希望本文所述对大家的Python程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- python实现TCP服务器端与客户端的方法详解
- python实现TCP服务器端与客户端的方法详解
- Python使用ftplib实现简易FTP客户端的方法
- Python使用ftplib实现简易FTP客户端的方法
- python实现简单ftp客户端的方法
- python实现简单ftp客户端的方法
- Python实现telnet服务器的方法
- Python实现telnet服务器的方法
- python实现连接mongodb的方法
- python使用smtplib模块通过gmail实现邮件发送的方法
- python实现在sqlite动态创建表的方法
- python实现在sqlite动态创建表的方法
- python使用smtplib模块通过gmail实现邮件发送的方法
- python实现连接mongodb的方法
- Python单例模式的4种实现方法 分类: python学习 2015-05-08 16:49 42人阅读 评论(0) 收藏
- Python单例模式的4种实现方法
- python实现中文输出的两种方法
- python使用xlrd实现检索excel中某列含有指定字符串记录的方法
- python使用xlrd实现检索excel中某列含有指定字符串记录的方法
- python实现中文输出的两种方法