Package com.ibm.di.fc.remotecmdlnfc
Class RemoteCmdLineExecutor
- java.lang.Object
-
- com.ibm.di.fc.remotecmdlnfc.RemoteCmdLineExecutor
-
- All Implemented Interfaces:
CmdLineExecutor
public class RemoteCmdLineExecutor extends java.lang.Object implements CmdLineExecutor
The CmdLineExecutor that connects to and executes commands on a remote machine
-
-
Constructor Summary
Constructors Constructor Description RemoteCmdLineExecutor(java.util.Properties p, LogProxy lp)Constructor for the RemoteCmdLineExecutor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbuildSingleCommand(java.lang.String cmdToExecute, java.lang.String[] args, java.lang.String argDelimiter)Constructs a single String that represents the command and all its arguments seperated with the specified delimiter.voidclose()Close the connection to the targetEntryexecuteCommand(java.lang.String cmdToExecute)Execute the command on the target machine.EntryexecuteCommand(java.lang.String cmdToExecute, java.lang.String[] args, java.lang.String argDelimiter)Execute the command on the target machine.chargetOSSeparator()Return the correct path separator for the target system.java.lang.StringgetRandomDir(java.lang.String path)Create a random directory on the target machine.com.ibm.tivoli.remoteaccess.RemoteAccessgetRXAProtocol()Return the connection object accessing the target machinebooleanprepareConnection()Create a connection with the target machinevoidremoveDir(java.lang.String dir)Remove a file/directory from the targetvoidsetExecutorCmdArgsEncoding(java.lang.String enc)Sets encoding for the command arguments before executing the actual commandvoidtransferFile(java.lang.String local, java.lang.String remote)Transfer file localStdin to remoteStdin.
-
-
-
Constructor Detail
-
RemoteCmdLineExecutor
public RemoteCmdLineExecutor(java.util.Properties p, LogProxy lp)Constructor for the RemoteCmdLineExecutor- Parameters:
p- The properties for the executor connectionlp- The LogProxy for logging
-
-
Method Detail
-
prepareConnection
public boolean prepareConnection() throws RemoteConnectException, ParamExceptionCreate a connection with the target machine- Specified by:
prepareConnectionin interfaceCmdLineExecutor- Returns:
- boolean value representing the success of the connection
- Throws:
RemoteConnectExceptionParamException
-
executeCommand
public Entry executeCommand(java.lang.String cmdToExecute) throws RemoteConnectException, GeneralCLFCException
Execute the command on the target machine.- Specified by:
executeCommandin interfaceCmdLineExecutor- Parameters:
cmdToExecute- The command to be executed- Returns:
- Entry object containing three output attributes: command.out, command.error and command.returnCode.
- Throws:
RemoteConnectExceptionGeneralCLFCException
-
executeCommand
public Entry executeCommand(java.lang.String cmdToExecute, java.lang.String[] args, java.lang.String argDelimiter) throws RemoteConnectException, GeneralCLFCException
Execute the command on the target machine.- Specified by:
executeCommandin interfaceCmdLineExecutor- Parameters:
cmdToExecute- The command to be executedargs- The command arguments as a String ArrayargDelimiter- The command argument delimiter- Returns:
- Entry object containing three output attributes: command.out, command.error and command.returnCode.
- Throws:
RemoteConnectExceptionGeneralCLFCException
-
getRandomDir
public java.lang.String getRandomDir(java.lang.String path) throws GeneralCLFCExceptionCreate a random directory on the target machine. Can be used to store temporary files.- Specified by:
getRandomDirin interfaceCmdLineExecutor- Parameters:
path- The path to the directory under which the random directory is to be created- Returns:
- String Representing the complete path to the random directory that was created
- Throws:
GeneralCLFCException- If random directory creation fails
-
transferFile
public void transferFile(java.lang.String local, java.lang.String remote) throws GeneralCLFCExceptionTransfer file localStdin to remoteStdin.- Specified by:
transferFilein interfaceCmdLineExecutor- Parameters:
local- Path to standard input source file on local machineremote- Path to standard input destination file on target machine- Throws:
GeneralCLFCException- If file transfer is unsuccessful
-
removeDir
public void removeDir(java.lang.String dir) throws GeneralCLFCExceptionRemove a file/directory from the target- Specified by:
removeDirin interfaceCmdLineExecutor- Parameters:
dir- Path to the file/folder to be removed on target machine- Throws:
GeneralCLFCException- If delete operation is unsuccessful
-
getOSSeparator
public char getOSSeparator() throws RemoteConnectExceptionReturn the correct path separator for the target system.- Specified by:
getOSSeparatorin interfaceCmdLineExecutor- Returns:
- char path separator on target machine
- Throws:
RemoteConnectException- If problems encountered obtaining the OS Separator.
-
close
public void close()
Close the connection to the target- Specified by:
closein interfaceCmdLineExecutor
-
buildSingleCommand
public java.lang.String buildSingleCommand(java.lang.String cmdToExecute, java.lang.String[] args, java.lang.String argDelimiter)Constructs a single String that represents the command and all its arguments seperated with the specified delimiter.- Parameters:
cmdToExecute- The command to be executedargs- The command arguments as a String ArrayargDelimiter- The command argument delimiter Return the connection object accessing the target machine- Returns:
- RemoteAccess RXA Connection object
-
getRXAProtocol
public com.ibm.tivoli.remoteaccess.RemoteAccess getRXAProtocol()
Return the connection object accessing the target machine- Returns:
- RemoteAccess RXA Connection object
-
setExecutorCmdArgsEncoding
public void setExecutorCmdArgsEncoding(java.lang.String enc)
Sets encoding for the command arguments before executing the actual command- Specified by:
setExecutorCmdArgsEncodingin interfaceCmdLineExecutor- Parameters:
enc- encoding to be used
-
-