telnetlib read_until
时间:2011-04-12
来源:互联网
用python写了一个脚本如下:
#!/usr/bin/python
import telnetlib,time
host='remotehost'
user = 'test'
pwd = 'test'
tn = telnetlib.Telnet(host)
tn.set_debuglevel('9')
tn.read_until("login: ", 10)
tn.write(user + '\n')
print tn.read_until("Password: ", 3)
tn.write(pwd + '\n')
tn.read_until("$", 1)
tn.write("cd / \n")
tn.write("ls \n")
print tn.read_until("ls \n", 10)
print tn.read_until("$", 1)
复制代码
当我打印出read_until时,为什么大数情况下没有command,结果如下:
[test@localhost ~]$ [test@localhost /]$ usr lib proc
bin proc
boot lost+found root var
media sbin
很少会有这样的结果:
cd /
ls
Last login: Tue Jan 11 04:35:28
[test@localhost ~]$ cd /
[test@localhost /]$ ls
bin lib proc usr
boot lost+found root var
b media sbin
[test@localhost /]$
#!/usr/bin/python
import telnetlib,time
host='remotehost'
user = 'test'
pwd = 'test'
tn = telnetlib.Telnet(host)
tn.set_debuglevel('9')
tn.read_until("login: ", 10)
tn.write(user + '\n')
print tn.read_until("Password: ", 3)
tn.write(pwd + '\n')
tn.read_until("$", 1)
tn.write("cd / \n")
tn.write("ls \n")
print tn.read_until("ls \n", 10)
print tn.read_until("$", 1)
复制代码
当我打印出read_until时,为什么大数情况下没有command,结果如下:
[test@localhost ~]$ [test@localhost /]$ usr lib proc
bin proc
boot lost+found root var
media sbin
很少会有这样的结果:
cd /
ls
Last login: Tue Jan 11 04:35:28
[test@localhost ~]$ cd /
[test@localhost /]$ ls
bin lib proc usr
boot lost+found root var
b media sbin
[test@localhost /]$
作者: leve1031 发布时间: 2011-04-12
回复 leve1031
怎么都没人回我呀。我打出telnet的debug信息,当不显示command的时候有这样一条
Telnet(remotehost,23): recv 'on an i686\r\n'
Telnet(remotehost,23): recv '\xf2'
Telnet(remotehost,23): recv 'login: '
这条是什么意思呀?
怎么都没人回我呀。我打出telnet的debug信息,当不显示command的时候有这样一条
Telnet(remotehost,23): recv 'on an i686\r\n'
Telnet(remotehost,23): recv '\xf2'
Telnet(remotehost,23): recv 'login: '
这条是什么意思呀?
作者: leve1031 发布时间: 2011-04-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28