Thread: [tcljava-user] Expect support
Brought to you by:
mdejong
From: Chet V. <che...@gm...> - 2007-11-08 15:34:59
|
Hi Sorry if this is a newbie question but I was wondering if there's support for Expect scripts. i.e can I run an expect script using the Jacl interpreter ? We use expect primarily for network admin tasks like login into devices/term servers via telnet/ssh and run commands. Any useful pointers would be appreciated. Thanks in advance, Chetan Vora |
From: D. J. H. <dha...@mi...> - 2007-11-08 16:05:31
|
You definitely would not be able to use the full power of expect from jacl, since that extension does some fairly low-level plumbing with Unix PTY's, forking, and process control. For telnet, you may be able to make socket connections and use a simplified version of expect -- I think I remember seeing some examples on the http://wiki.tcl.tk site. SSH would be harder because you would need to either write your own channel implementation using a pure-Java ssh implementation (like jsch) or do your own tricks with Runtime.exec and piped Input/Output streams and threads. Hope this helps, -=- D. J. Chet Vora wrote: > Sorry if this is a newbie question but I was wondering if there's > support for Expect scripts. i.e can I run an expect script using the > Jacl interpreter ? We use expect primarily for network admin tasks > like login into devices/term servers via telnet/ssh and run commands. > Any useful pointers would be appreciated. > > Thanks in advance, > Chetan Vora > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > > |
From: Mo D. <mo...@mo...> - 2007-11-08 17:41:00
|
Chet Vora wrote: > Hi > > Sorry if this is a newbie question but I was wondering if there's > support for Expect scripts. i.e can I run an expect script using the > Jacl interpreter ? We use expect primarily for network admin tasks > like login into devices/term servers via telnet/ssh and run commands. > Any useful pointers would be appreciated. > Hi Chet There is zero chance of expect working in Jacl. It depends on low level IO stuff that Java just does not support. You could use expect in Tcl Blend though. Mo DeJong |
From: Justin R. <ju...@ha...> - 2007-11-08 19:42:10
|
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. The library is commented and unit tests are used to keep the library in check is expect's original behavior. BUT there is little documentation. For me, expect4j saved the day. If anyone is interested in using this library I'd be happy to walk you through it. I'll use that as motivation for writing the documentation. Justin Ryan Halfempty Industries (1) http://code.google.com/p/enchanter/ (2) http://expectj.sourceforge.net/ On 11/8/07, Mo DeJong <mo...@mo...> wrote: > Chet Vora wrote: > > Hi > > > > Sorry if this is a newbie question but I was wondering if there's > > support for Expect scripts. i.e can I run an expect script using the > > Jacl interpreter ? We use expect primarily for network admin tasks > > like login into devices/term servers via telnet/ssh and run commands. > > Any useful pointers would be appreciated. > > > Hi Chet > > There is zero chance of expect working in Jacl. It depends on low level > IO stuff that Java just > does not support. You could use expect in Tcl Blend though. > > Mo DeJong > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > |
From: Tom P. <tpo...@ny...> - 2007-11-09 14:57:50
|
On Thu, Nov 08, 2007 at 02:41:47PM -0500, Justin Ryan wrote: > http://code.google.com/p/expect4j/ > Nice work! -- Tom Poindexter tpo...@ny... |
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 |
From: Chet V. <che...@gm...> - 2007-11-09 01:37:23
|
Thanks to everyone for responding. Justin, thanks for the links....the enchanter project looks interesting from our vantage point at first glance. It would be cool if its possible to integrate a Java scripting API to it.(jsr223) Regards, CV On Nov 8, 2007 5:59 PM, Mo DeJong <mo...@mo...> wrote: > > 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 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > |