Class 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 target
      Entry 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 machine
      boolean prepareConnection()
      Create a connection with the target machine
      void removeDir​(java.lang.String dir)
      Remove a file/directory from the target
      void setExecutorCmdArgsEncoding​(java.lang.String enc)
      Sets encoding for the command arguments before executing the actual command
      void transferFile​(java.lang.String local, java.lang.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​(java.util.Properties p,
                                     LogProxy lp)
        Constructor for the RemoteCmdLineExecutor
        Parameters:
        p - The properties for the executor connection
        lp - The LogProxy for logging
    • Method Detail

      • 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 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 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 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​(java.lang.String local,
                                 java.lang.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​(java.lang.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
      • close

        public void close()
        Close the connection to the target
        Specified by:
        close in interface CmdLineExecutor
      • 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 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​(java.lang.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