Package expectj

ExpectJ can be used for automating interaction with either a process (through stdin / stdout) or a telnet session.

See:
          Description

Interface Summary
Executor This interface exists for people who want control over how processes are launched.
Spawnable Implementors of this interface can be spawned by ExpectJ.
 

Class Summary
ExpectJ This class is the starting point of the ExpectJ Utility.
Spawn This class is used for talking to processes / ports.
 

Exception Summary
ExpectJException This class extends the Exception class and encapsulates other exceptions.
TimeoutException Timeout while waiting for a Spawn.
 

Package expectj Description

ExpectJ can be used for automating interaction with either a process (through stdin / stdout) or a telnet session.

It is a Java implementation of the Unix expect utility.

Here's an example for how a short shell session can be automated. A TimeoutException will be thrown on timeout of one of the expect() calls.

// Create a new ExpectJ object with a timeout of 5s
ExpectJ expectinator = new ExpectJ(5);

// Fork the process
Spawn shell = expectinator.spawn("/bin/sh");

// Talk to it
shell.send("echo Chunder\n");
shell.expect("Chunder");
shell.send("exit\n");
shell.expectClose();

// Done!



Copyright © 2009. All Rights Reserved.