com.ibm.di.fc.remotecmdlnfc
Interface CmdLineExecutor

All Known Implementing Classes:
RemoteCmdLineExecutor

public interface CmdLineExecutor

The object that connects to the target machine, executes the commands and returns the results.


Method Summary
 void close()
          Close the connection to the target
 Entry executeCommand(String cmd)
          Execute the command on the target machine.
 Entry executeCommand(String cmd, 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.
 boolean prepareConnection()
          Create a connection with the target machine
 void removeDir(String dirPath)
          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 localStdin, String remoteStdin)
          Transfer file localStdin to remoteStdin.
 

Method Detail

executeCommand

Entry executeCommand(String cmd)
                     throws GeneralCLFCException
Execute the command on the target machine.

Parameters:
cmd - The command to be executed
Returns:
Entry object containing three output attributes: command.out, command.error and command.returnCode.
Throws:
GeneralCLFCException - When an exception occurs trying to execute the command remotely.

executeCommand

Entry executeCommand(String cmd,
                     String[] args,
                     String argDelimiter)
                     throws GeneralCLFCException
Execute the command on the target machine.

Parameters:
cmd - 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:
GeneralCLFCException - When an exception occurs trying to execute the command remotely.

prepareConnection

boolean prepareConnection()
                          throws GeneralCLFCException
Create a connection with the target machine

Returns:
boolean value representing the success of the connection
Throws:
GeneralCLFCException

getRandomDir

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

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

void transferFile(String localStdin,
                  String remoteStdin)
                  throws GeneralCLFCException
Transfer file localStdin to remoteStdin.

Parameters:
localStdin - Path to standard input source file on local machine
remoteStdin - Path to standard input destination file on target machine
Throws:
GeneralCLFCException - If file transfer is unsuccessful

removeDir

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

Parameters:
dirPath - Path to the file/folder to be removed on target machine
Throws:
GeneralCLFCException - If delete operation is unsuccessful

getOSSeparator

char getOSSeparator()
                    throws GeneralCLFCException
Return the correct path separator for the target system.

Returns:
char path separator on target machine
Throws:
GeneralCLFCException - If problems encountered obtaining the OS Separator.

close

void close()
Close the connection to the target


setExecutorCmdArgsEncoding

void setExecutorCmdArgsEncoding(String enc)
Sets encoding for the command arguments before executing the actual command

Parameters:
enc - encoding to be used