|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jclouds.tools.ant.util.SSHExecute
public class SSHExecute
Executes a command on a remote machine via ssh.
adapted from SSHBase and SSHExec ant tasks, and Execute from the ant 1.7.1 release.
| Constructor Summary | |
|---|---|
SSHExecute()
Creates a new execute object using PumpStreamHandler for stream handling. |
|
SSHExecute(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
Creates a new ssh object. |
|
| Method Summary | |
|---|---|
static void |
closeStreams(com.jcraft.jsch.ChannelExec process)
Close the streams belonging to the given Process. |
int |
execute(String command)
Execute the command on the remote host. |
protected com.jcraft.jsch.Session |
openSession()
Open an ssh seession. |
void |
setHost(String host)
Remote host, either DNS name or IP. |
void |
setKeyfile(String keyfile)
Sets the keyfile for the user. |
void |
setKnownhosts(String knownHosts)
Sets the path to the file that has the identities of all known hosts. |
void |
setPassphrase(String passphrase)
Sets the passphrase for the users key. |
void |
setPassword(String password)
Sets the password for the user. |
void |
setPort(int port)
Changes the port used to connect to the remote host. |
void |
setProject(org.apache.tools.ant.Project project)
Used for logging |
void |
setStreamHandler(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
Set the stream handler to use. |
void |
setTimeout(long timeout)
The connection can be dropped after a specified number of milliseconds. |
void |
setTrust(boolean yesOrNo)
Setting this to true trusts hosts whose identity is unknown. |
void |
setUsername(String username)
Username known to remote host. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SSHExecute()
PumpStreamHandler for stream handling.
public SSHExecute(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
streamHandler - the stream handler used to handle the input and output streams of the subprocess.| Method Detail |
|---|
public void setStreamHandler(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
streamHandler - ExecuteStreamHandler.public void setTrust(boolean yesOrNo)
yesOrNo - if true trust the identity of unknown hosts.public void setProject(org.apache.tools.ant.Project project)
public void setUsername(String username)
username - The new username valuepublic void setPassword(String password)
password - The new password valuepublic void setKeyfile(String keyfile)
keyfile - The new keyfile valuepublic void setPassphrase(String passphrase)
passphrase - The new passphrase valuepublic void setHost(String host)
host - The new host valuepublic void setPort(int port)
port - port number of remote host.public void setTimeout(long timeout)
timeout - The new timeout value in secondspublic void setKnownhosts(String knownHosts)
knownHosts - a path to the known hosts file.
public int execute(String command)
throws org.apache.tools.ant.BuildException,
com.jcraft.jsch.JSchException,
IOException,
TimeoutException
command - - what to execute on the remote host.
org.apache.tools.ant.BuildException - bad parameter.
com.jcraft.jsch.JSchException - if there's an underlying problem exposed in SSH
IOException - if there's a problem attaching streams.
TimeoutException - if we exceeded our timeout
protected com.jcraft.jsch.Session openSession()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException - on error
public static void closeStreams(com.jcraft.jsch.ChannelExec process)
throws IOException
process - the Process.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||