Class ExpectJ
- java.lang.Object
-
- com.santaba.agent.groovyapi.expect.expectj.ExpectJ
-
public class ExpectJ extends java.lang.Object
This class is the starting point of the ExpectJ Utility. This class acts as factory for allSpawn
s.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 aSpawnable
.Spawn
spawn(java.lang.String command)
This method spawns a new process.Spawn
spawn(java.lang.String hostName, int port)
This method spawns a telnet connection to the given host and port number.Spawn
spawn(java.lang.String remoteHostName, int remotePort, java.lang.String userName, java.lang.String password, java.lang.String preferredLibrary)
This method creates a spawn that controls an SSH connection.
-
-
-
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 java.io.IOException
This method launches aSpawnable
. Further expect commands can be invoked on the returnedSpawn
object.- Parameters:
spawnable
- spawnable to be executed- Returns:
- The newly spawned process
- Throws:
java.io.IOException
- if the spawning fails
-
spawn
public Spawn spawn(java.lang.String command) throws java.io.IOException
This method spawns a new process. Further expect commands can be invoked on the returnedSpawn
object.- Parameters:
command
- command to be executed- Returns:
- The newly spawned process
- Throws:
java.io.IOException
- if the process spawning fails- See Also:
Runtime.exec(String)
-
spawn
public Spawn spawn(Executor executor) throws java.io.IOException
This method spawns a new process. Further expect commands can be invoked on the returnedSpawn
object.- Parameters:
executor
- Will be called upon to start the new process- Returns:
- The newly spawned process
- Throws:
java.io.IOException
- if the process spawning fails- See Also:
Runtime.exec(String[])
-
spawn
public Spawn spawn(java.lang.String hostName, int port) throws java.io.IOException
This method spawns a telnet connection to the given host and port number. Further expect commands can be invoked on the returnedSpawn
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:
java.io.IOException
- if the telnet spawning failsjava.net.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 java.io.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:
java.io.IOException
- If taking control over the SSH channel fails.- See Also:
#spawn(String, int, String, String)
,SshSpawn(Channel)
-
spawn
public Spawn spawn(java.lang.String remoteHostName, int remotePort, java.lang.String userName, java.lang.String password, java.lang.String preferredLibrary) throws java.io.IOException, java.lang.IllegalArgumentException
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 authenticatepassword
- The password with which to authenticate- Returns:
- A spawn controlling the SSH channel.
- Throws:
java.io.IOException
- If taking control over the SSH channel fails.java.lang.IllegalArgumentException
- If the userName is null.- See Also:
spawn(Channel)
,SshSpawn(String, int, String, String)
-
-