Re: [tcljava-user] tcljava-user Digest, Vol 20, Issue 2
Brought to you by:
mdejong
From: Justin R. <ju...@ha...> - 2008-03-08 20:33:35
|
> IMO, spawn command is what creates a connection to the process so that it is accessible for other Expect commands. So, If I run the telnet client outside my tcl script, how does it work other Expect commands. My understanding is that you are running telnetserver.jar as one process. Then, you want to connect to it using a telnet client and then automate the connection using expect. Right? In C-based expect, when you run the command 'spawn telnet' it runs the system's telnet client. Since the process was started by tcl, it has control of child process's stdin and stdout. The process connects via tcp and handles all the weird telnet protocol stuff that goes on. Expect uses the stdin and stdout to do its fancy expect/send statements. Example of running: > package require expect > spawn /usr/bin/telnet hostname > expect "login: " In expect4j, to be as platform independent as possible, the spawn command runs jakarta's commons-net library to connect via telnet. The library simulates as much as possible, so you can the above command just fine. The example found in the wiki (http://code.google.com/p/expect4j/wiki/Installation) is: > package require java > java::load expect4j.ExpectEmulation > package require expect > > spawn telnet 192.168.0.1 > expect "login: " > send "root\r" > expect "Password:" > send "supersecret\r" > expect "root@router:~# " Your email pushed to be document some of this stuff. So I think you'll find the example matches your initial email pretty closely. Further instructions pertaining to classpath can be found in the wiki too. If you have any problems. I'd love to hear them. If anyone knows how I can avoid the "java::load expect4j.ExpectEmulation", when running from tcl.lang.Shell, I'd love to know how. I've previously orchestrated the Intrep from my java program, and had it load my class before running some a tcl scipt. This way I can take c-based expect scripts and run them seamlessly. Justin Ryan Halfempty Industries |