com.ibm.di.fc.remotecmdlnfc
Class RemoteCmdLineExecutor

java.lang.Object
  extended by com.ibm.di.fc.remotecmdlnfc.RemoteCmdLineExecutor
All Implemented Interfaces:
CmdLineExecutor

public class RemoteCmdLineExecutor
extends Object
implements CmdLineExecutor

The CmdLineExecutor that connects to and executes commands on a remote machine


Constructor Summary
RemoteCmdLineExecutor(Properties p, LogProxy lp)
          Constructor for the RemoteCmdLineExecutor
 
Method Summary
 String buildSingleCommand(String cmdToExecute, String[] args, 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 target
 Entry executeCommand(String cmdToExecute)
          Execute the command on the target machine.
 Entry executeCommand(String cmdToExecute, String[] args, String argDelimiter)
          Execute the command on the target machine.
 char getOSSeparator()
          Return the correct path separator for the target system.
 String getRandomDir(String path)
          Create a random directory on the target machine.
 com.ibm.tivoli.remoteaccess.RemoteAccess getRXAProtocol()
          Return the connection object accessing the target machine
 boolean prepareConnection()
          Create a connection with the target machine
 void removeDir(String dir)
          Remove a file/directory from the target
 void setExecutorCmdArgsEncoding(String enc)
          Sets encoding for the command arguments before executing the actual command
 void transferFile(String local, String remote)
          Transfer file localStdin to remoteStdin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteCmdLineExecutor

public RemoteCmdLineExecutor(Properties p,
                             LogProxy lp)
Constructor for the RemoteCmdLineExecutor

Parameters:
p - The properties for the executor connection
lp - The LogProxy for logging
Method Detail

prepareConnection

public boolean prepareConnection()
                          throws RemoteConnectException,
                                 ParamException
Create a connection with the target machine

Specified by:
prepareConnection in interface CmdLineExecutor
Returns:
boolean value representing the success of the connection
Throws:
RemoteConnectException
ParamException

executeCommand

public Entry executeCommand(String cmdToExecute)
                     throws RemoteConnectException,
                            GeneralCLFCException
Execute the command on the target machine.

Specified by:
executeCommand in interface CmdLineExecutor
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(String cmdToExecute,
                            String[] args,
                            String argDelimiter)
                     throws RemoteConnectException,
                            GeneralCLFCException
Execute the command on the target machine.

Specified by:
executeCommand in interface CmdLineExecutor
Parameters:
cmdToExecute - The command to be executed
args - The command arguments as a String Array
argDelimiter - The command argument delimiter
Returns:
Entry object containing three output attributes: command.out, command.error and command.returnCode.
Throws:
RemoteConnectException
GeneralCLFCException

getRandomDir

public String getRandomDir(String path)
                    throws GeneralCLFCException
Create a random directory on the target machine. Can be used to store temporary files.

Specified by:
getRandomDir in interface CmdLineExecutor
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(String local,
                         String remote)
                  throws GeneralCLFCException
Transfer file localStdin to remoteStdin.

Specified by:
transferFile in interface CmdLineExecutor
Parameters:
local - Path to standard input source file on local machine
remote - Path to standard input destination file on target machine
Throws:
GeneralCLFCException - If file transfer is unsuccessful

removeDir

public void removeDir(String dir)
               throws GeneralCLFCException
Remove a file/directory from the target

Specified by:
removeDir in interface CmdLineExecutor
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 interface CmdLineExecutor
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 interface CmdLineExecutor

buildSingleCommand

public String buildSingleCommand(String cmdToExecute,
                                 String[] args,
                                 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 executed
args - The command arguments as a String Array
argDelimiter - 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(String enc)
Sets encoding for the command arguments before executing the actual command

Specified by:
setExecutorCmdArgsEncoding in interface CmdLineExecutor
Parameters:
enc - encoding to be used