其他优于基于 TCL 的 Expect 的解决方案/语言?

发布于 2024-09-19 17:03:11 字数 1432 浏览 10 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝眼泪 2024-09-26 17:03:11

还有更多。

坦率地说,最初的 Expect——Tcl Expect——是最好的。与它的任何后继者相比,它更好地支持“交互”和各种 pty 怪癖。就其所做的事情而言,它没有优越者。

然而,与此同时,大多数 Expect 用户只利用了 Expect 功能的一小部分,因此这种技术优势对他们来说并不重要。几乎在所有情况下,我建议来自 Perl 的人使用 Expect.pm,熟悉 Python 的人依赖 Pexpect,等等。

将 Perl 与“... Awk 和 Perl”进行天真的比较是没有根据的。

抽象地说,所有常见的脚本语言——Lua、awk、sh、Tcl、Ruby、Perl、Python……——都是差不多的。期待稍微但非常有效地将这个共同核心扩展到 pty 意识的方向(这个故事还有一些我们暂时可以忽略的内容)。粗略地说,如果您的自动化涉及输入不可见的密码,那么您需要 Expect。 Awk 和 Perl 不内置此功能。

还有其他适用于其他情况的自动化工具。

There's more to it.

Bluntly, the original Expect--the Tcl Expect--is the best one. It better supports "interact" and various pty eccentricities than any of its successors. It has no superior, for what it does.

HOWEVER, at the same time, most Expect users exploit such a small fraction of Expect's capabilities that this technical superiority is a matter of indifference to them. In nearly all cases, I advise someone coming from Perl to use Expect.pm, someone familiar with Python to rely on Pexpect, and so on.

Naive comparisons of Perl with "... Awk and also Perl" are ill-founded.

In the abstract, all the common scripting languages--Lua, awk, sh, Tcl, Ruby, Perl, Python, ...--are about the same. Expect slightly but very effectively extends this common core in the direction of pty-awareness (there's a little more to the story that we can neglect for the moment). Roughly speaking, if your automation involves entering an invisible password, you want Expect. Awk and Perl do NOT build in this capability.

There are other automation tools for other contexts.

眸中客 2024-09-26 17:03:11

查看 Perl 的 Expect

Check out Expect for Perl

眼角的笑意。 2024-09-26 17:03:11

ajsie 问道:“您还在谈论哪些其他自动化工具?”

我将回答一个不同的问题:“我还考虑到哪些其他情况”?答案是:除了 stdio 之外的任何交互式环境。例如,Expect 不适用于 GUI 点击的自动化。 Expect 也不适用于 Win* 非控制台应用程序,即使它们看起来像是面向字符的(存在这种情况)。

一个令人兴奋的反现实:期望古怪设备的自动化,允许通过类似术语的连接进行控制。如果您的柴油发动机(或更典型的是电信铁)表示可以通过连接类似 telnet 的进程(甚至通过旧式串行线路)来监控它,那么您就处于 Expect 有机会的域中发挥其魔力。

ajsie asks, "Which other automation tools are you talking about?"

I'll answer a different question: "which other contexts do I have in mind"? The answer: any interactive environment OTHER than a stdio one. Expect is NOT for automation of GUI points-and-clicks, for example. Expect is also not available for Win* non-console applications, even if they look as though they are character-oriented (such exist).

An exciting counter-realization: Expect is for automation of wacky equipment that permits control by a term-like connection. If your diesel engine (or, more typically, telecomm iron) says it can be monitored by hooking up a telnet-like process (even through an old-style serial line, say), you're in a domain where Expect has a chance to work its magic.

坏尐絯℡ 2024-09-26 17:03:11

查看 Python 的 Pexpect

Check out Pexpect for Python

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文