跨平台解决方案,用于自动执行ncurses型telnet会话 [英] Cross platform solution for automating ncurses-type telnet sessions

查看:92
本文介绍了跨平台解决方案,用于自动执行ncurses型telnet会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我在网络和电信方面的部分工作涉及在旧硬件无法在其他界面中提供简单解决方案的情况下自动执行telnet会话.只能通过常规端口(RS-232串行端口),SNMP或telnet访问许多较旧的设备.有时telnet是访问特定信息的唯一方法,但是telnet被设计为人机界面,因此需要屏幕抓取.此外,还有刮屏问题,其中仅更新部分以节省带宽(请参见 ncurses ).在我的工作中,我使用了ActiveState Expect和Python telnet库.

Part of my work in networking and telco involves automating telnet sessions when legacy hardware doesn't offer easy solutions in other interfaces. Many older pieces of equipment can only be accessed via craft ports (RS-232 serial ports), SNMP, or telnet. Sometimes telnet is the only way to access specific information, however telnet is designed as a human interface and thus requires screen scraping. In addition, there is also the issue of scraping screens where only portions are updated in order to save bandwidth (see ncurses). In my work I have used ActiveState Expect and the Python telnet library.

问题

哪些语言和库能够自动进行telnet会话,并具有以下要求:

Which languages and libraries are able to automate telnet sessions and have the following requirements:

  • Suitable for large projects (e.g. Tcl doesn't seem to scale as well as Python in my experience and seems outdated)
  • Cross Platform (e.g. Pexpect does not work on Windows and Activestate Expect behaves differently on Windows plus requires DEP on newer machines to be turned off)
  • Able to screen scrape sessions that repaint portions of the screen (similar to the behavior of ncurses in command-line programs)
  • Free as in beer!

一个优选的解决方案还包括以下内容:

A preferable solution would also include the following:

  • 易于重新分配(例如,不 需要在计算机上安装一些庞大的运行时.)
  • 还适用于SSH,串行连接和其他命令行界面.
  • Easily redistributable (e.g. Does not require some huge runtime to be installed on a machine.)
  • Also works for SSH, serial connections, and other command-line interfaces.

推荐答案

看看ActiveTcl发行版中的demos/Expect/term_expect.它模拟可光标寻址的终端,并允许您在特定的屏幕位置测试输出.在文件末尾查看示例屏幕抓取代码.

Take a look at demos/Expect/term_expect in the ActiveTcl distribution. It emulates a cursor-addressable terminal and allows you to test output at specific screen locations. Check out the example screen-scraping code at the end of the file.

这篇关于跨平台解决方案,用于自动执行ncurses型telnet会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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