如何用Java挂钩系统级? [英] how to hook into system level expect with Java?

查看:248
本文介绍了如何用Java挂钩系统级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另请参阅有关此主题的更好的问题

See also a better question, more specific, on this topic.

我只是发现期望,一种基于tcl的脚本语言,用于自动化,特别是telnet连接:

I've just discovered expect, a tcl based scripting language for automating, among other things, telnet connections:

thufir@mordor:~/NetBeansProjects/expect$ 
thufir@mordor:~/NetBeansProjects/expect$ expect example rainmaker.wunderground.com 3000
spawn telnet rainmaker.wunderground.com 3000
Trying 38.102.137.140...
Connected to rainmaker.wunderground.com.
Escape character is '^]'.
------------------------------------------------------------------------------
*               Welcome to THE WEATHER UNDERGROUND telnet service!            *
------------------------------------------------------------------------------
*                                                                            *
*   National Weather Service information provided by Alden Electronics, Inc. *
*    and updated each minute as reports come in over our data feed.          *
*                                                                            *
*   **Note: If you cannot get past this opening screen, you must use a       *
*   different version of the "telnet" program--some of the ones for IBM      *
*   compatible PC's have a bug that prevents proper connection.              *
*                                                                            *
*           comments: jmasters@wunderground.com                              *
------------------------------------------------------------------------------

Press Return to continue:usage: send [args] string
    while executing
"send – – "\r""
    (file "example" line 9)
thufir@mordor:~/NetBeansProjects/expect$ 

什么机制是是可以用Java挂钩,还是用Java期望?是的,有 http://tcljava.sourceforge.net/ 以及其他几个,但他们看起来已经过时了。

What mechanisms are available to either hook into expect with Java, or into Java with expect? Yes, there are http://tcljava.sourceforge.net/ as well as a few others, but they seem out of date.

如果在Java中有tcl实现,为什么不这样,那我的确有效。但是,我推断,由于缺乏对网页的更新,没有任何内容可以完全实现...

If there's a tcl implementation in Java, and why not, that would work, I'm sure. However, I'm inferring, from the lack of updates to web pages, that nothing was ever fully implemented...

维基百科说:

Java

expect4j — an attempt at a Java clone of the original Expect
ExpectJ — a Java implementation of the Unix expect utility
Expect-for-Java — pure Java implementation of the Expect tool

然而,expect4j表示这是一次尝试,ExpectJ自2010年以来一直没有改变,而且Expect-for-Java也没有被触及多年。

However, expect4j says that it's an attempt, ExpectJ hasn't been changed since 2010, and Expect-for-Java also hasn't been touched in years.

如果使用这些库并正常运行,我很抱歉,但是日期表明它们没有被维护。

If these libraries are used and functioning, my apologies, but the dates indicated that they aren't maintained.

我宁愿单独使用expect和Java,但是这样他们互动是否有用于在两者之间传递消息的钩子或机制?

I would rather use expect and Java separately, but so that they interact. Is there a hook or mechanism for passing messages between the two?

---------------------- ------------------------------------- UPDATE ----------

-----------------------------------------------------------UPDATE----------

**


Jacl是一个用Java编写的Tcl 8.x解释器。您可以在Tcl中编写
Java应用程序的脚本。

Jacl is a Tcl 8.x interpreter written in Java. You can script your Java applications in Tcl.

**

http://wiki.tcl.tk/1215

但是,图书馆有一段时间没有被触及过。我不太确定它的效果如何。我不知道它是否支持 expect 之类的东西,看起来各种期望尝试不是维持。

However, the library hasn't been touched in some time. I'm not quite sure how well it works. I don't know whether it supports anything like expect or not, it looks like the various expect attempts are not being maintained.

Donal Fellows的回答很可能是没有真正的解决方案,这是正确的。但是,可能只能使用这个tcl库来启动telnet会话,调用真正的telnet,而不是使用流程构建器,但这是非常试探性的。

Most likely the answer by Donal Fellows, that there's no real solution, is correct. However, it might just be possible to use this tcl library to initiate a telnet session, invoking real telnet, and not with process builder, but that's very tentative.

推荐答案

我创建了另一个Java期望库 ExpectIt (未在维基百科中列出)实现交互循环。看看这个例子

I have created yet another Java expect library ExpectIt (not listed in Wikipedia) which implements interact loop. Have a look at this example.

这篇关于如何用Java挂钩系统级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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