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.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.void
close()
Close the connection to the targetEntry
executeCommand(java.lang.String cmdToExecute)
Execute the command on the target machine.Entry
executeCommand(java.lang.String cmdToExecute, java.lang.String[] args, java.lang.String argDelimiter)
Execute the command on the target machine.char
getOSSeparator()
Return the correct path separator for the target system.java.lang.String
getRandomDir(java.lang.String path)
Create a random directory on the target machine.com.ibm.tivoli.remoteaccess.RemoteAccess
getRXAProtocol()
Return the connection object accessing the target machineboolean
prepareConnection()
Create a connection with the target machinevoid
removeDir(java.lang.String dir)
Remove a file/directory from the targetvoid
setExecutorCmdArgsEncoding(java.lang.String enc)
Sets encoding for the command arguments before executing the actual commandvoid
transferFile(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, ParamException
Create a connection with the target machine- Specified by:
prepareConnection
in interfaceCmdLineExecutor
- Returns:
- boolean value representing the success of the connection
- Throws:
RemoteConnectException
ParamException
-
executeCommand
public Entry executeCommand(java.lang.String cmdToExecute) throws RemoteConnectException, GeneralCLFCException
Execute the command on the target machine.- Specified by:
executeCommand
in interfaceCmdLineExecutor
- Parameters:
cmdToExecute
- The command to be executed- Returns:
- Entry object containing three output attributes: command.out, command.error and command.returnCode.
- Throws:
RemoteConnectException
GeneralCLFCException
-
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:
executeCommand
in 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:
RemoteConnectException
GeneralCLFCException
-
getRandomDir
public java.lang.String getRandomDir(java.lang.String path) throws GeneralCLFCException
Create a random directory on the target machine. Can be used to store temporary files.- Specified by:
getRandomDir
in 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 GeneralCLFCException
Transfer file localStdin to remoteStdin.- Specified by:
transferFile
in 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 GeneralCLFCException
Remove a file/directory from the target- Specified by:
removeDir
in 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 RemoteConnectException
Return the correct path separator for the target system.- Specified by:
getOSSeparator
in 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:
close
in 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:
setExecutorCmdArgsEncoding
in interfaceCmdLineExecutor
- Parameters:
enc
- encoding to be used
-
-