python实现telnet客户端的方法
作者:令狐不聪 时间:2021-04-14 21:07:24
本文实例讲述了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,telnet
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python keras.metrics源代码分析
2023-10-28 20:58:14
用JavaScript实现UrlEncode和UrlDecode功能
2008-01-27 11:30:00
Python算法之栈(stack)的实现
2022-09-01 15:26:15
python regex库实例用法总结
2023-11-02 12:17:27
python机器学习理论与实战(四)逻辑回归
2021-07-19 21:05:12
![](https://img.aspxhome.com/file/2023/3/101313_0s.jpg)
加快Firefox 3.5启动速度的方法
2009-07-16 15:22:00
Python2.7+pytesser实现简单验证码的识别方法
2022-01-18 02:37:33
一个统计当前在线用户的解决方案
2007-10-13 19:27:00
python调试工具Birdseye的使用教程
2023-08-22 19:18:48
![](https://img.aspxhome.com/file/2023/4/93714_0s.gif)
无忧 月影出书啦《JavaScript王者归来》
2008-01-09 13:45:00
![](https://img.aspxhome.com/file/UploadPic/20081/9/200819135150291s.gif)
如何提高网页的维护效率
2009-03-01 11:33:00
Python库 Bokeh 数据可视化实用指南
2022-09-28 14:54:51
![](https://img.aspxhome.com/file/2023/2/107122_0s.png)
Django实现文件上传下载功能
2023-06-13 20:09:46
![](https://img.aspxhome.com/file/2023/9/85009_0s.gif)
编写一个asp代码执行器
2007-09-24 16:05:00
Python转换字典成为对象,可以用"."方式访问对象属性实例
2021-06-01 09:01:50
python利用有道翻译实现"语言翻译器"的功能实例
2021-08-21 02:47:38
![](https://img.aspxhome.com/file/2023/7/84137_0s.png)
Django权限设置及验证方式
2022-12-28 23:45:18
Windows 下更改 jupyterlab 默认启动位置的教程详解
2023-06-11 13:10:12
![](https://img.aspxhome.com/file/2023/5/59145_0s.png)
vitrualBox+ubuntu16.04安装python3.6最新教程及详细步骤
2021-06-26 05:34:38
![](https://img.aspxhome.com/file/2023/7/103437_0s.jpg)
ASP实现防止网站被采集代码
2011-03-25 10:40:00