我刚刚发现了期望,一种基于tcl的脚本语言,用于自动进行telnet连接:
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插入到Expect中,或者通过Java插入到Expect中?是的,有http://tcljava.sourceforge.net/以及其他一些,但是它们似乎已经过时了。
我敢肯定,如果Java中有tcl实现,为什么不行,那行得通。但是,由于缺乏网页更新,我推断没有任何东西可以完全实施…
维基百科说:
爪哇
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年以来就没有更改过,而且Java的Expect-for-Java也没有被触及多年。
如果使用了这些库并使其正常运行,我表示歉意,但是日期表明它们没有得到维护。
我宁愿分别使用Expect和Java,但要使它们交互。是否存在在两者之间传递消息的挂钩或机制?
-------------------------------------------------- ---------更新----------
**
Jacl是用Java编写的Tcl 8.x解释器。您可以在Tcl中编写Java应用程序的脚本。
**
但是,该库已经有一段时间没有被使用过了。我不太确定它的效果如何。我不知道它是否支持任何东西expect,似乎各种expect尝试都没有得到维护。
Donal Fellows的回答很可能是没有真正的解决方案,这是正确的。但是, 也许
可以使用此tcl库来启动telnet会话,调用真正的telnet,而不是通过进程生成器来启动,但这是非常尝试的。