- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我用 python 编写了一个脚本,它使用 telnetlib 模块远程登录到 linux 设备,运行 install.sh 文件,然后在完成后重新启动。在完成 install.sh 脚本后,我添加了一行,用于向终端发送 echo“install complete”。不幸的是,read_until("install complete") 和 expect(["install complete"]) 没有检测到这个回显。
tn = telnetlib.Telnet(ip)
tn.read_until("login: ")
tn.write(user + "\n")
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("cd [file path to the install script]")#echoes "install complete" when finished
tn.write("./install.sh\n")
tn.read_until("install complete") #where the process hangs returns None if I add timeout parameter
telnetlib 是否无法到达 echo 语句,或者我应该使用其他模块或语言吗?如果我手动运行安装程序,我可以按预期确认“安装完成”回声。
最佳答案
所示代码在 cd 命令后不包含换行符 ("\n"),因此实际发送的数据可能是 "cd somepath./install.sh\n"而不会工作...
此外,我会避免在此处使用术语“echo”,因为在 telnet 中,“echo”实际上是将您发送的字符发送回给您的部分(用于远程回显)。在这种情况下,无论发生与否,read_until() 都不会关心。简而言之,这根本不是回声。
关于python - Telnetlib read_until() 和 expect() 未检测到终端回显,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18519518/
我想检查使用 telnetlib 的连接是否仍然存在。 我这样做的方式是发送 ls命令并检查答案,但我确信必须有更流畅的解决方案。 最佳答案 我从 here 得到了这个想法,所以向他们致敬,代码可能是
我正在为 IBM as400 机器开发 telnet 客户端,但在返回正确数量的数据时遇到了一些麻烦。最初,程序应该连接到一个 telnet session ,该 session 具有写入的用户名和密
我正在尝试制作一个脚本,它通过 telnet 连接到服务器。我正在使用 python 和 telnetlib。我在超时工作时遇到问题。我想在连接到主机时使用可选超时,以便在主机不在线时得到异常。 我已
我编写了一个 python 脚本,可以通过读取列出不同 IP 地址的 csv 文件来顺序登录多个设备。从那里,它为每个设备输出一个文件,其中包含通过脚本传递到设备的一些命令的内容。所以我已经走了很远了
背景:我正在拉动防火墙的连接表,以便构建一个最高的谈话者/监听者列表。 在某些情况下,连接表有 200,000 多个条目。我正在使用 telnetlib 远程连接到防火墙并获取连接表。我使用 read
我有以下 python 代码: import telnetlib ts = telnetlib.Telnet('192.168.0.2') ts.set_debuglevel(10) ts.read_
[Python telnetlib read_until recv问题] “read_until”函数返回带有长命令的截断字符串。 命令运行完美,但不显示完整文本。 我怎样才能解决这个问题?请帮忙。
网络专家在这里玩编码 我有一个非常基本的脚本,可以远程登录到交换机/路由器,运行一些命令并终止。一切都是在端口 23 上完成的。我遇到的问题是,当我通过术语服务器连接到设备或通过非标准端口连接到 ES
我有一些 Python 代码,通过 telnet 连接到 OSPF 守护进程(由 Quagga 运行),然后执行以下操作: tn.write("show ip ospf database router
我正在使用 Python 模块 telnetlib 创建一个 telnet session (与国际象棋服务器),我遇到了一个我真的无法解决的问题。以下代码完美运行: >>> f = login("m
我正在编写一个简单的程序,它通过 telnet 与路由器通信并向它发出一些简单的命令。我希望能够测试这些命令,确保程序正确响应服务器输出并在正确的时刻发送命令。但是我想不出一个好的方法来做到这一点。我
我正在使用 Python 的 telnetlib 远程登录到某台机器并执行一些命令,我想获得这些命令的输出。 那么,目前的情况是什么—— tn = telnetlib.Telnet(HOST) t
所以我正在尝试 python 文档给出的这个非常简单的示例: import getpass import sys import telnetlib HOST = "" user = raw_input
我正在尝试在我的 Ubuntu 15.4 操作系统上安装一个名为 telnetlib 的 python 模块。 我试过: $ pip install telnetlib 但我得到错误: root@c-
我正在尝试打开一个 telnet 连接,写入一个字符串,然后用 Python 从 telnet 服务器打印所有内容。我想我遗漏了一些明显的东西,因为文档看起来很不言自明,并且在终端中做我认为完全相同的
我想使用select.select()阻止循环,直到准备好从 telnet session 列表中读取一些数据。但是,下面的代码不起作用,对 select.select() 的调用立即返回,没有数据可
我有一个基本的聊天服务器,我可以很容易地通过 telnet 连接到它。我只需输入主机和端口,无需任何进一步的身份验证,就可以开始输入服务器可以解释的命令。为了模拟用户流量,我想创建一个脚本来打开 te
我正在编写一个库来支持远程登录到远程服务器并运行应用程序。 在建立连接、取回数据、解析等方面一切进展顺利(至少与通过文本界面与程序通信一样顺畅)。 一个app如果正常进入会改变光标,如果失败则保留原来
我通过访问设备从 telnetlib 获得覆盖的输出,但我不知道如何解决它以获得正确的输出。 我尝试了以下代码: import re import os import sys import time
我正在通过 telnet 连接到硬件设备。该设备在 I/O 方面非常简单。所以我向它提交一个命令,然后设备一次一行地输出数据,每秒一次。每行仅包含一个数字。 所以我的问题是:如果我使用 python
我是一名优秀的程序员,十分优秀!