com.tivoli.twg.procman.api
Class ExecuteCommandAPI

java.lang.Object
  extended bycom.tivoli.twg.libs.Command
      extended bycom.tivoli.twg.procman.ExecuteCommand
          extended bycom.tivoli.twg.procman.api.ExecuteCommandAPI

public class ExecuteCommandAPI
extends com.tivoli.twg.procman.ExecuteCommand

This class encapulates for the SDK the ability to execute commands on agents.

Note: DOS based commands for NT/9X plaforms must include invokation of the appropriate command process. For example:

NT - cmd /c dir c:\

9X - command.com /c dir c:\

The command string passed in may have to include appropriate quotes if any paths in the command contain spaces (e.g. Program Files).


Field Summary
 
Fields inherited from class com.tivoli.twg.libs.Command
CMD_SENDER_FLAG, CMDRET_CREATE_CMDPKT_FAILED, CMDRET_ENCRYPT_FAIL, CMDRET_ENQUEUE_LOCAL_FAILED, CMDRET_INVALID_DEST_ADDRESS, CMDRET_NO_LOCAL_SVCNODE_IMPL, CMDRET_SECURE_FAIL, CMDRET_SEND_BUFFER_FAILED, CMDRET_SEND_FAILED, CMDRET_SEND_TIMEOUT, CMDRET_SERVICEFAILED, CMDRET_SESS_DISABLED_LCL, CMDRET_SESS_DISABLED_RMT, CMDRET_SESS_UNAVAIL_LCL, CMDRET_SESS_UNAVAIL_RMT, CMDRET_SESS_WAIT_DONE, CMDRET_SESS_WAIT_EXPIRED, CMDRET_SESS_WAITING, COMMAND_TYPE_INPUT, COMMAND_TYPE_OUTPUT, DEFAULT_CMD_TIMEOUT, ENQUEUE_FAILED_COPYDATA, ENQUEUE_FAILED_NO_DESTPATH, ENQUEUE_FAILED_NO_PROCESS_HANDLE, ENQUEUE_FAILED_NO_SVC_NODE_HANDLE, ENQUEUE_FAILED_SECURITY, ENQUEUE_GENERAL_FAILURE, JNI_BUFFER_NULL, JNI_ENTRY_POINT_NOT_LOADED, JNI_HANDLE_NULL, JNI_INITIALIZE_FAILED, RMI_LOOKUP_ERROR, SESSION_NONE, SESSION_PREFERRED, SESSION_REQUIRED
 
Constructor Summary
ExecuteCommandAPI()
          This is a constructor for the ExecuteCommand object.
 
Method Summary
 boolean buildCommandLine()
          Called after all data set.
 boolean deserialize(byte[] stream)
          Take a serialized ExecuteCommand object and deserialize it and load data
 boolean getAsynch()
          Indicates if ansync command execution set.
 boolean getCapture()
          Indicates if output capture is set
 java.lang.String getCommandLine()
          Get the command line string previoulsy provided
 java.lang.String getCWD()
          Get the current working directory previously specified.
 int getExecRC()
          Get the execution return code returned by the agent executing the command
 byte[] getOutput()
          Return output in the form of a byte array.
 java.lang.String getPassword()
          Get the password set in the command
 boolean getSynch()
          Indicates if synchronous command execution set.
 long getTargetMOID()
          Get the target MOID previously set.
 int getTimeout()
          Get the timeout value set
 java.lang.String getUserId()
          Get the user ID set in the command
 boolean isReady()
          Indicates that the command has been built successfully and is ready to be sent to the agent
 byte[] serialize()
          Serialize the data in this object for storage purposes.
 void setAsynch(boolean async)
          Sets if command should be run asynch or synchronously.
 void setCapture(boolean capture)
          Sets/unsets command output capture flags.
 void setCommandLine(java.lang.String cmdLine)
          Specify the command line to be executed
 void setCWD(java.lang.String workingDir)
          Set the working directory where the command will be executed
 boolean setDestinationFromMoid(long targetMoid)
          Given a MOID, this method retrieves the destination address from the server.
 boolean setDestinationFromMoid(long targetMoid, ServiceNode sn)
          Give a MOID, the method retrieves the destination address from the server.
 void setPassword(java.lang.String password)
          Set the password of the user ID previously set for execution of the command under a specific user.
 void setTimeout(int timeout)
          Set the timeout period for command execution.
 void setUserId(java.lang.String ID)
          Set the user ID the command will be executed under.
 
Methods inherited from class com.tivoli.twg.procman.ExecuteCommand
addParameter, getEnvironment, isEnvironment, mapRCtoResource, setDestinationMoid, setEnvironment, setExecutable, setNoWindow, setParameters, setSynch
 
Methods inherited from class com.tivoli.twg.libs.Command
AddInputParm, AddInputParm, AddObjectAsInputParm, AddObjectAsOutputParm, AddOutputParm, AddOutputParm, addToDebugStrings, AllocateBuffer, AttachInputParm, AttachOutputParm, CmdId, CommandCode, commandCodeDebugString, CommandComplete, CompressObject, debugPrint, DecompressObject, DestinationAddress, DetachInputParm, DetachOutputParm, FreeBuffer, FreeInputsAfterSend, getCmdType, GetObjectFromInputParm, GetObjectFromOutputParm, getSenderServiceNode, hexDump, InputParm, InputParm, InputParmLength, IsFlatInputBuffer, IsFlatOutputBuffer, IsPostponedReply, MakeFlatInputBuffer, MakeFlatOutputBuffer, NumInputParms, NumOutputParms, OutputParm, OutputParm, OutputParmLength, PostponeReply, ResetIndex, ResetInput, ResetOutput, ReturnAddress, ReturnCode, ReturnCodeToString, RootDestinationAddress, RootReturnAddress, SessionHold, SessionMode, SessionRelease, SessionWaitTime, setCmdType, setCmdTypeInput, setCmdTypeOutput, SetCommandCode, setCommandCodeDebugString, setCommandCompleteListener, SetDestinationAddress, SetNewID, SetReturnAddress, SetReturnCode, setSenderServiceNode, SetSessionHold, SetSessionMode, SetSessionRelease, SetSessionWaitTime, SetTimeOut, TimeOut, toString, UseFlatInputBuffer, UseFlatOutputBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExecuteCommandAPI

public ExecuteCommandAPI()
This is a constructor for the ExecuteCommand object.

Method Detail

setDestinationFromMoid

public boolean setDestinationFromMoid(long targetMoid)
Given a MOID, this method retrieves the destination address from the server. The address is massaged to address this command to the Process Manager subsystem, and the Command destination is set accordingly. The command is sent to the server down the console default service node.

Parameters:
targetMoid - MOID to retrieve destination address for
Returns:
booelan true is successful

setDestinationFromMoid

public boolean setDestinationFromMoid(long targetMoid,
                                      ServiceNode sn)
Give a MOID, the method retrieves the destination address from the server. The address is massaged to address this command to the Process Manager subsystem, and the Command destination is set accordingly. The command is sent to the server down the specified service node.

Parameters:
targetMoid - MOID to retrieve destination address for
sn - service node to be used to retrieve data
Returns:
boolean true if successful

setCommandLine

public void setCommandLine(java.lang.String cmdLine)
Specify the command line to be executed

Parameters:
cmdLine - command line to be executed

setTimeout

public void setTimeout(int timeout)
Set the timeout period for command execution. If not timeout is specified, the default timeout of 2 minutes is used. This is used when output capture is requested.

Parameters:
timeout - timeout period in seconds

getTimeout

public int getTimeout()
Get the timeout value set

Returns:
int timeout value in seconds

buildCommandLine

public boolean buildCommandLine()
Called after all data set. This method fills in all of the input params of the command to prepare the object to be sent to the agent to be processed.

Returns:
boolean true if all input parameters successfully built
See Also:
Command

getCommandLine

public java.lang.String getCommandLine()
Get the command line string previoulsy provided

Returns:
String command line

isReady

public boolean isReady()
Indicates that the command has been built successfully and is ready to be sent to the agent

Returns:
boolean true means the command is ready to be sent

setCapture

public void setCapture(boolean capture)
Sets/unsets command output capture flags. Requests data be returned in compressed unicode if the agent supports it.

Parameters:
capture - true turns output capture on, false turns off output capture

getCapture

public boolean getCapture()
Indicates if output capture is set

Returns:
boolean true output capture on

setAsynch

public void setAsynch(boolean async)
Sets if command should be run asynch or synchronously. If ansync, you output capture will be sent to false.

Parameters:
async - true forces the command to execute asynchronously

getAsynch

public boolean getAsynch()
Indicates if ansync command execution set.

Returns:
boolean true if async set.

getSynch

public boolean getSynch()
Indicates if synchronous command execution set.

Returns:
boolean true if synch. set

setUserId

public void setUserId(java.lang.String ID)
Set the user ID the command will be executed under.

Parameters:
ID - user ID

getUserId

public java.lang.String getUserId()
Get the user ID set in the command

Returns:
String user ID previously set

setPassword

public void setPassword(java.lang.String password)
Set the password of the user ID previously set for execution of the command under a specific user.

Parameters:
password - password

getPassword

public java.lang.String getPassword()
Get the password set in the command

Returns:
String password previously set

getExecRC

public int getExecRC()
Get the execution return code returned by the agent executing the command

Returns:
int return code

getOutput

public byte[] getOutput()
Return output in the form of a byte array. Newer agents (>= 2.1) will return the data in compUnicode.

Returns:
byte[] containing output from command.

setCWD

public void setCWD(java.lang.String workingDir)
Set the working directory where the command will be executed

Parameters:
workingDir - directory where the command will be executed

getCWD

public java.lang.String getCWD()
Get the current working directory previously specified.


getTargetMOID

public long getTargetMOID()
Get the target MOID previously set.

Returns:
long MOID

serialize

public byte[] serialize()
Serialize the data in this object for storage purposes.

Returns:
byte[] contains the serialized data

deserialize

public boolean deserialize(byte[] stream)
Take a serialized ExecuteCommand object and deserialize it and load data

Returns:
boolean true if deserialized with no errors