It connects to a telnet server. Sends your login credentials and then executes the unix command ls. Then exits the session and prints all output from the telnet server.
You may want to consider Exscript as well. It simplifies some of the easy tasks but for more complicated there is additional level of abstraction (Exscript is a scripting language in itself). Either way - worth checking out.
发布评论
评论(3)
有一个用于 telnet 连接的 python 库,可以从 telnet 连接读取数据或向 telnet 连接写入数据。
检查链接。它有一些您正在寻找的基本示例。
以下是链接中的示例:
它连接到 telnet 服务器。发送您的登录凭据,然后执行 unix 命令
ls
。然后退出会话并打印 telnet 服务器的所有输出。There's a python library for telnet connections that reads and writes from/to a telnet connection.
Check the link. It has some basic examples of what you are looking for.
Here's an example from the link:
It connects to a telnet server. Sends your login credentials and then executes the unix command
ls
. Then exits the session and prints all output from the telnet server.您可能还需要考虑 Exscript 。它简化了一些简单的任务,但对于更复杂的任务,有额外的抽象级别(Exscript 本身就是一种脚本语言)。无论哪种方式 - 都值得一试。
You may want to consider Exscript as well. It simplifies some of the easy tasks but for more complicated there is additional level of abstraction (Exscript is a scripting language in itself). Either way - worth checking out.
我自己从未使用过它,但也许 pexpect 就是您所需要的?
I've never used it myself, but maybe pexpect is what you need?