Re: [tcljava-user] Expect support
Brought to you by:
mdejong
From: Mo D. <mo...@mo...> - 2007-11-08 22:59:09
|
Justin Ryan wrote: > In the Java space you have a few options for ssh/telnet scripting. The > cleanest implementation I've seen is enchanter (1). While expectj (2) > is more compliant with actual expect library. I learned this while > investigating a expect solution for tcljava, and I also found that my > best option was to just write one myself which supports not only > expect in java but also the bindings needed for tcljava. The library > is called expect4j: > > http://code.google.com/p/expect4j/ > > expect4j is aimed at supporting the functionality of the C-based > expect library, started by Don Libes, in java and tcljava. The > library is written in java and uses a bootstrap class called > ExpectEmulation of load the relevant bindings into a tcljava Intrep. > The most important tcl functions have been implement, e.g. expect, > send, spawn. A full list of supported functions and global variables > are commented in ExpectEmulation.java. I've successfully ported a > 100K tcl script based on expect to tcljava, without any changes, by > just using expect4j. > > One of the major limitations is that only ssh and telnet are supported > by the spawn command. This was done to limit interactions with > Runtime.exec(), and to keep the library completely in the java space. > This avoids the need for process control, forking, and PTYs. On the > otherhand, the Expect4j class can be used for automating any > InputStream/OutputStream or Socket. One of the unit tests shows how > to automate the "cmd /c net statistics Workstation" command on > Windows. For support of ssh/telnet, Jsch is used for ssh and > commons-net is used for telnet. The expect command can also match > against many different regexps/strings, unlike the other expect-like > libraries. ORO is used for the pattern matching. > > Hi Justin Thanks for posting this note, I did not know there was a useful expect implementation out there for Jacl. BTW, if you are looking for a home for the project, I really have no problem with adding your expect implementation to the standard Jacl distro. Jacl already has Itcl bundled with it. There are some issues that would need to be ironed out (license, regexp impl, and so on) but it should work, if you are interested. cheers Mo DeJong |