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.
Spawnable.CloseListener Will be notified when a Spawnable closes.
 

Class Summary
AbstractSpawnable Base class for spawnables providing an AbstractSpawnable.onClose() method that should be called on close.
ExpectJ This class is the starting point of the ExpectJ Utility.
ProcessSpawn This class spawns a process that ExpectJ can control.
Spawn This class is used for talking to processes / ports.
SshSpawn A Spawnable for controlling an SSH session using ExpectJ.
 

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 © 2010. All Rights Reserved.