|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hp.ucmdb.discovery.library.clients.BaseClient com.hp.ucmdb.discovery.library.clients.shell.ShellClient
public abstract class ShellClient
ShellClient
runs shell commands.
Thd principle methods are executeCmd
and executeCmdWithTimeOut
. The output of these methods
is the console output of shell this client represents.
# Example: Creating a telnet client
client = Framework.getClientFactory(ClientsConsts.TELNET_PROTOCOL_NAME).createClient()
output = client.executeCmd('df -P')
com.hp.ucmdb.discovery.probe.clients.ClientsConsts
,
ClientFactory
Field Summary | |
---|---|
static java.lang.String |
UNIX_CMD_SEPARATOR
|
static java.lang.String |
WIN_CMD_SEPARATOR
|
Fields inherited from class com.hp.ucmdb.discovery.library.clients.BaseClient |
---|
CREDENTIALS_ID, ENCODING |
Constructor Summary | |
---|---|
ShellClient(ClientsFrameworkImpl framework,
java.util.Properties props,
java.lang.String clientType)
|
Method Summary | |
---|---|
boolean |
canCopyFile()
|
boolean |
deleteFile(java.lang.String remoteFileName,
java.lang.String remoteShareName)
|
java.lang.String |
executeCmd(java.lang.String cmd)
Runs the specified command. |
java.lang.String |
executeCmd(java.lang.String cmd,
boolean readUntilTimeout)
Runs the specified command until completion or timeout. |
java.lang.String |
executeCmd(java.lang.String cmd,
int cmdTimeout)
Runs the specified command until completion or the specified timeout. |
java.lang.String |
executeCmd(java.lang.String cmd,
int cmdTimeout,
boolean readUntilTimeout)
Runs the specified command until completion or the specified timeout. |
java.lang.String |
executeCmdWithTimeOut(java.lang.String cmd)
Runs the specified command until completion or timeout. |
java.lang.String |
getFile(java.lang.String remoteFileName,
java.lang.String remoteShareName)
|
byte[] |
getLastCommandOutputBytes()
|
int |
getMaxCommandLength()
Returns the maximum length (bytes) of a command that can be sent to this client. |
java.lang.String |
getServerPort()
Returns the server port from the protocol properties. |
java.lang.String |
getWelcomeBuffer()
|
java.lang.String |
putFile(java.lang.String localFileName,
java.lang.String remoteShareName)
|
void |
setCharset(java.nio.charset.Charset charset)
|
void |
setMaxCommandLength(int maxCommandLength)
Sets the maximum length (bytes) of a command that can be sent to this client. |
Methods inherited from class com.hp.ucmdb.discovery.library.clients.BaseClient |
---|
close, getClientType, getCredentialId, getIpAddress, getProperty, getShellCmdSeperator, getSudoCommands, getSudoPaths, getTimeout, getUserName, isConnected, supportsSudo |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UNIX_CMD_SEPARATOR
public static final java.lang.String WIN_CMD_SEPARATOR
Constructor Detail |
---|
public ShellClient(ClientsFrameworkImpl framework, java.util.Properties props, java.lang.String clientType) throws java.lang.Exception
java.lang.Exception
Method Detail |
---|
public java.lang.String getWelcomeBuffer()
public java.lang.String executeCmdWithTimeOut(java.lang.String cmd) throws java.lang.Exception
cmd
- The command to run
java.lang.Exception
- on connection errorpublic java.lang.String executeCmd(java.lang.String cmd) throws java.lang.Exception
cmd
- The command to run
java.lang.Exception
- on connection error or timeoutpublic java.lang.String executeCmd(java.lang.String cmd, boolean readUntilTimeout) throws java.lang.Exception
cmd
- The command to runreadUntilTimeout
- The effect of this parameter is implementation dependent
java.lang.Exception
public java.lang.String executeCmd(java.lang.String cmd, int cmdTimeout) throws java.lang.Exception
cmd
- The command to runcmdTimeout
- The timeout in milliseconds
java.lang.Exception
public java.lang.String executeCmd(java.lang.String cmd, int cmdTimeout, boolean readUntilTimeout) throws java.lang.Exception
cmd
- The command to runcmdTimeout
- The timeout in millisecondsreadUntilTimeout
- If true, the command fails if the default timeout is reached.
If false, the command runs to completion or until it throws a fatal error.
java.lang.Exception
public byte[] getLastCommandOutputBytes() throws java.lang.Exception
java.lang.Exception
public void setCharset(java.nio.charset.Charset charset)
public java.lang.String getServerPort() throws java.lang.Exception
java.lang.Exception
public boolean canCopyFile()
public java.lang.String getFile(java.lang.String remoteFileName, java.lang.String remoteShareName) throws java.lang.Exception
java.lang.Exception
public java.lang.String putFile(java.lang.String localFileName, java.lang.String remoteShareName) throws java.lang.Exception
java.lang.Exception
public boolean deleteFile(java.lang.String remoteFileName, java.lang.String remoteShareName) throws java.lang.Exception
java.lang.Exception
public int getMaxCommandLength()
public void setMaxCommandLength(int maxCommandLength)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |