com.hp.ucmdb.discovery.library.clients.shell
Class NTCMDClient

java.lang.Object
  extended by com.hp.ucmdb.discovery.library.clients.BaseClient
      extended by com.hp.ucmdb.discovery.library.clients.shell.ShellClient
          extended by com.hp.ucmdb.discovery.library.clients.shell.NTCMDClient

public class NTCMDClient
extends ShellClient

NTCMDClient provides APIs for executing shell commands on hosts running a Windows OS. For a creation example, see ShellClient.
Properties that can be redefined for NTCMDClient:

In addition to executing a remote shell command, the NTCMDClient can copy a file to the remote host, execute it on the remote, and bring back its console output. Here is a Jython code example for a coping utility that obtains disk information on remote machine:

 props = Properties()
 # Next two lines specify the absolute path where utility file exists. By default, this code points
 # to $DiscoveryProbe_INSATALLDIRroot\lib\collectors\probeManager\discoveryResources\, but any folder can be specified.
 agent_root_dir=CollectorsParameters.BASE_PROBE_MGR_DIR
 agent_ext_dir = agent_root_dir + CollectorsParameters.getDiscoveryResourceFolder() + '\\diskinfo.exe'
 props.setProperty(AgentConstants.PROP_NTCMD_AGENT_START_FLAGS, '/C:' + agent_ext_dir + ' /D');

 # 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.
 xcmd = Framework.getClientFactory(ClientsConsts.NTCMD_PROTOCOL_NAME).createClient(props)
 # Execute the command
        buffer = xcmd.executeCmd('diskinfo')
 

See Also:
ShellClient, ClientFactory, com.hp.ucmdb.discovery.probe.clients.ClientsConsts

Field Summary
 
Fields inherited from class com.hp.ucmdb.discovery.library.clients.shell.ShellClient
UNIX_CMD_SEPARATOR, WIN_CMD_SEPARATOR
 
Fields inherited from class com.hp.ucmdb.discovery.library.clients.BaseClient
CREDENTIALS_ID, ENCODING
 
Constructor Summary
NTCMDClient(ClientsFrameworkImpl framework, java.util.Properties props)
           
 
Method Summary
 boolean canCopyFile()
          Checks whether files can be copied.
 boolean deleteFile(java.lang.String remoteFileName, java.lang.String remoteShareName)
          Deletes the specified file.
 java.lang.String getFile(java.lang.String remoteFileName, java.lang.String remoteShareName)
          Copies a file from the remote host.
 java.lang.String putFile(java.lang.String localFileName, java.lang.String remoteShareName)
          Copies a local file to the remote host.
 
Methods inherited from class com.hp.ucmdb.discovery.library.clients.shell.ShellClient
executeCmd, executeCmd, executeCmd, executeCmd, executeCmdWithTimeOut, getLastCommandOutputBytes, getMaxCommandLength, getServerPort, getWelcomeBuffer, setCharset, setMaxCommandLength
 
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
 

Constructor Detail

NTCMDClient

public NTCMDClient(ClientsFrameworkImpl framework,
                   java.util.Properties props)
            throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

canCopyFile

public boolean canCopyFile()
Checks whether files can be copied.

Overrides:
canCopyFile in class ShellClient
Returns:
true if the client can copy files to the remote machine

deleteFile

public boolean deleteFile(java.lang.String remoteFileName,
                          java.lang.String remoteShareName)
                   throws java.lang.Exception
Deletes the specified file.

Overrides:
deleteFile in class ShellClient
Parameters:
remoteFileName - The name of the file on remote host to delete
remoteShareName - The path to the shared folder containing the file to delete
Returns:
true if deletion successful
Throws:
java.lang.Exception

getFile

public java.lang.String getFile(java.lang.String remoteFileName,
                                java.lang.String remoteShareName)
                         throws java.lang.Exception
Copies a file from the remote host.

Overrides:
getFile in class ShellClient
Parameters:
remoteFileName - The name of the file to copy
remoteShareName - The path to the shared folder containing the file to copy
Returns:
The local name of the copied file
Throws:
java.lang.Exception

putFile

public java.lang.String putFile(java.lang.String localFileName,
                                java.lang.String remoteShareName)
                         throws java.lang.Exception
Copies a local file to the remote host.

Overrides:
putFile in class ShellClient
Parameters:
localFileName - The fully qualified local path and name of the file to copy
remoteShareName - The path to the shared folder into which to copy the file
Returns:
The name of the copied file on the remote machine
Throws:
java.lang.Exception


Documentation Feedback
Copyright 2010 Hewlett-Packard Development Company, L.P.