public class NTCMDClient extends ShellClient
NTCMDClient
provides APIs for executing shell commands on hosts running a Windows OS.
For a creation example, see ShellClient
.
java.util.List
) specified by
AgentConstants.PROP_AGENT_OUTPUT_MATCHERS
is the list of strings
that indicate end-of-output to the client. The output is considered finished when
any one of the matchers is encountered. Methods of this class do not return
any information about which matcher was encountered.
In session mode, by default the client changes the prompt of
the remote shell to a known string and adds it to the matchers list. This
means that completion of regular shell commands are correctly identified and
control returned to the shell. It is rare, but this will fail if the prompt
string appears in the output.
AgentConstants.PROP_NTCMD_AGENT_START_FLAGS
and put a
java.util.List
of java.util.String
that reflect
the flags as they would appear in the command line.
props = Properties()
props.setProperty(AgentConstants.PROP_NTCMD_AGENT_START_FLAGS, '/L');
# During client creation and connection, this file will be copied to ADMIN$\\System32\ on the remote computer.
# By default, this directory is in the system PATH.
ntcmd = Framework.getClientFactory(ClientsConsts.NTCMD_PROTOCOL_NAME).createClient(props)
# Execute the command
buffer = ntcmd.executeCmd('diskinfo')
ShellClient
,
ClientFactory
,
ClientsConsts
BaseClient.FilteredMethodsHandler
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ERRORLEVEL_COMMAND |
UNIX_CMD_SEPARATOR, WIN_CMD_SEPARATOR
CREDENTIALS_ID, ENCODING
Constructor and Description |
---|
NTCMDClient(ClientsFrameworkImpl framework,
java.util.Properties props) |
NTCMDClient(ClientsFrameworkImpl framework,
java.util.Properties props,
java.lang.String protocolType) |
Modifier and Type | Method and Description |
---|---|
boolean |
canCopyFile()
Checks whether files can be copied.
|
boolean |
deleteFile(java.lang.String remoteFileName,
java.lang.String remoteShareName)
Deletes the specified file.
|
int |
downloadFile(java.lang.String localFilePath,
java.lang.String remoteFilePath,
ExistingFileResolution localFileResolution)
Download the specified file (remoteFilePath) from remote machine to probe.
|
int |
getBandwidthLimit()
Gets bandwidth limit for file operations in kilobits per second.
|
java.lang.String |
getFile(java.lang.String remoteFileName,
java.lang.String remoteShareName) |
java.lang.String |
putFile(java.lang.String localFileName,
java.lang.String remoteShareName) |
void |
setBandwidthLimit(int limit)
Sets bandwidth limit for file operations in kilobits per second.
|
int |
uploadFile(java.lang.String localFilePath,
java.lang.String remoteFilePath,
ExistingFileResolution remoteFileResolution)
Upload the specified file (localFilePath) from probe's machine to remote machine
|
deleteOption, executeCmd, executeCmd, executeCmd, executeCmd, executeCmd, executeCmdWithTimeOut, getErrorVariable, getLastCommandOutputBytes, getMaxCommandLength, getOptionsDirectory, getOptionsMap, getRemotePlatform, getServerPort, getWelcomeBuffer, setCharset, setErrorVariable, setMaxCommandLength, setOptionIfNotExist, setOptionsDirectory, setOptionsMap, setOptionsMap, setRemotePlatform
addDeniedPackage, close, getClientType, getCredentialId, getIpAddress, getProperty, getShellCmdSeperator, getSudoCommands, getSudoPaths, getTimeout, getUserName, isConnected, setAttributeEncrypted, supportsSudo
public static final java.lang.String ERRORLEVEL_COMMAND
public NTCMDClient(ClientsFrameworkImpl framework, java.util.Properties props) throws java.lang.Exception
java.lang.Exception
public NTCMDClient(ClientsFrameworkImpl framework, java.util.Properties props, java.lang.String protocolType) throws java.lang.Exception
java.lang.Exception
public boolean canCopyFile()
canCopyFile
in class ShellClient
public void setBandwidthLimit(int limit)
BandwidthControl
setBandwidthLimit
in interface BandwidthControl
setBandwidthLimit
in class ShellClient
limit
- bandwidth limitpublic int getBandwidthLimit()
BandwidthControl
getBandwidthLimit
in interface BandwidthControl
getBandwidthLimit
in class ShellClient
public boolean deleteFile(java.lang.String remoteFileName, java.lang.String remoteShareName) throws java.lang.Exception
deleteFile
in class ShellClient
remoteFileName
- The name of the file on remote host to deleteremoteShareName
- The path to the shared folder containing the file to deletejava.lang.Exception
public int uploadFile(java.lang.String localFilePath, java.lang.String remoteFilePath, ExistingFileResolution remoteFileResolution) throws java.lang.Exception
uploadFile
in interface RemoteFileSystemManager
uploadFile
in class ShellClient
localFilePath
- - the path of the file to be upload from probe machineremoteFilePath
- - the path of the uploaded file on remote machineremoteFileResolution
- - defines behavior if the file on remote machine already exists.java.lang.Exception
- - exception is thrown in case the upload failed.public int downloadFile(java.lang.String localFilePath, java.lang.String remoteFilePath, ExistingFileResolution localFileResolution) throws java.lang.Exception
downloadFile
in interface RemoteFileSystemManager
downloadFile
in class ShellClient
localFilePath
- - defines the name of downloaded file on probe's machine.remoteFilePath
- - the path of the downloaded file on remote machine.localFileResolution
- - defines behavior if the localFilePath already exists on probe machine.java.lang.Exception
- - exception is thrown in case of download failed.public java.lang.String putFile(java.lang.String localFileName, java.lang.String remoteShareName) throws java.lang.Exception
putFile
in class ShellClient
java.lang.Exception
public java.lang.String getFile(java.lang.String remoteFileName, java.lang.String remoteShareName) throws java.lang.Exception
getFile
in class ShellClient
remoteFileName
- -
file name we want to get from remote machineremoteShareName
- -
name of the remote share from which we want to get the filejava.lang.Exception
Documentation Feedback
Copyright 2012 Micro Focus or one of its affiliates.