expectj
Class ExpectJ

java.lang.Object
  extended by expectj.ExpectJ

public class ExpectJ
extends Object

This class is the starting point of the ExpectJ Utility. This class acts as factory for all Spawns.

Author:
Sachin Shekar Shetty

Constructor Summary
ExpectJ()
          Create a new ExpectJ with an infinite timeout.
ExpectJ(long defaultTimeoutSeconds)
          Create a new ExpectJ with specified timeout setting.
 
Method Summary
 Spawn spawn(com.jcraft.jsch.Channel channel)
          This method creates a spawn that controls an SSH connection.
 Spawn spawn(Executor executor)
          This method spawns a new process.
 Spawn spawn(Spawnable spawnable)
          This method launches a Spawnable.
 Spawn spawn(String command)
          This method spawns a new process.
 Spawn spawn(String hostName, int port)
          This method spawns a telnet connection to the given host and port number.
 Spawn spawn(String remoteHostName, int remotePort, String userName, String password)
          This method creates a spawn that controls an SSH connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpectJ

public ExpectJ(long defaultTimeoutSeconds)
Create a new ExpectJ with specified timeout setting.

Parameters:
defaultTimeoutSeconds - default time out in seconds for the expect commands on the spawned process. -1 default time out indicates indefinite timeout.

ExpectJ

public ExpectJ()
Create a new ExpectJ with an infinite timeout.

Method Detail

spawn

public Spawn spawn(Spawnable spawnable)
            throws IOException
This method launches a Spawnable. Further expect commands can be invoked on the returned Spawn object.

Parameters:
spawnable - spawnable to be executed
Returns:
The newly spawned process
Throws:
IOException - if the spawning fails

spawn

public Spawn spawn(String command)
            throws IOException
This method spawns a new process. Further expect commands can be invoked on the returned Spawn object.

Parameters:
command - command to be executed
Returns:
The newly spawned process
Throws:
IOException - if the process spawning fails
See Also:
Runtime.exec(String)

spawn

public Spawn spawn(Executor executor)
            throws IOException
This method spawns a new process. Further expect commands can be invoked on the returned Spawn object.

Parameters:
executor - Will be called upon to start the new process
Returns:
The newly spawned process
Throws:
IOException - if the process spawning fails
See Also:
Runtime.exec(String[])

spawn

public Spawn spawn(String hostName,
                   int port)
            throws IOException
This method spawns a telnet connection to the given host and port number. Further expect commands can be invoked on the returned Spawn object.

Parameters:
hostName - The name of the host to connect to.
port - The remote port to connect to.
Returns:
The newly spawned telnet session.
Throws:
IOException - if the telnet spawning fails
UnknownHostException - if you specify a bogus host name
See Also:
TelnetSpawn, spawn(String, int, String, String), spawn(Channel)

spawn

public Spawn spawn(com.jcraft.jsch.Channel channel)
            throws IOException
This method creates a spawn that controls an SSH connection.

Parameters:
channel - The SSH channel to control.
Returns:
A spawn controlling the SSH channel.
Throws:
IOException - If taking control over the SSH channel fails.
See Also:
spawn(String, int, String, String), SshSpawn.SshSpawn(Channel)

spawn

public Spawn spawn(String remoteHostName,
                   int remotePort,
                   String userName,
                   String password)
            throws IOException
This method creates a spawn that controls an SSH connection.

Parameters:
remoteHostName - The remote host to connect to.
remotePort - The remote port to connect to.
userName - The user name with which to authenticate
password - The password with which to authenticate
Returns:
A spawn controlling the SSH channel.
Throws:
IOException - If taking control over the SSH channel fails.
See Also:
spawn(Channel), SshSpawn.SshSpawn(String, int, String, String)


Copyright © 2010. All Rights Reserved.