python行编辑telnet服务器 [英] python line editing telnet server

查看:104
本文介绍了python行编辑telnet服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用python创建服务器(它的作用无关紧要),但是我希望它接受telnet连接并提供具有行编辑功能(tabcompletion,emacs/vi-mode等)的命令行界面,每个会话的历史记录.我已经成功创建了telnet会话,禁用了线路模式并启用了服务器回显.

I am creating a server in python (what it is doing is irrelevant), but I would like it to accept telnet connections and provide a command line interface with line editing capabilities (tabcompletion, emacs/vi-mode, etc) and history per session. I have successfully created the telnet session, disabled line mode and enabled server echo.

我最初的想法是使用readline,但是python readline模块似乎仅适用于stdin上的单个会话;并检查似乎是其工作方式的底层readline库.

My initial thoughts were using readline but the python readline module seems to only work for a single session on stdin; and examining the underlying readline library that seems to be the way it works.

但是我想做的是为每个客户端创建一个实例(如果需要,可以称其为状态),并且随着接收到该状态的字符(字节)而被接收.生成完整的行后,它将把它传递给可以对其进行解析的服务器.

What I would like to do however is to create an instance (call it state if you like) for each client, and as characters (bytes) are received feed to the state. Once a complete line has been generated it would pass it to the server which may parse it.

所以我的问题是,如果有一个可以处理这种事情的库,甚至一个c库就足够了.

So my question is if there is a library which handles this kind of thing, even a c-library would be sufficient.

编辑:为澄清起见,我已经有一个功能齐全的服务器,但是我希望将telnet界面作为附件来重新配置,获取信息等.

EDIT: To clarify, I've got a fully functional server already, but I want the telnet interface as an add on to reconfigure, get information, etc.

推荐答案

听起来您已经对TELNET部分进行了排序,现在您想提供shell中常见的功能,例如BASH,KSH等.我没有我自己尝试过,但是看起来像 shython :具有bash和python功能的通用外壳"

It sounds like you've got the TELNET part sorted, and now you want to provide features commonly found in shells like BASH, KSH etc. I've not tried it myself, but have a look as shython: "a versatile shell having features of both bash and python".

这篇关于python行编辑telnet服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆