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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Close the connection to the target
      Entry executeCommand​(java.lang.String cmd)
      Execute the command on the target machine.
      Entry executeCommand​(java.lang.String cmd, 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.
      boolean prepareConnection()
      Create a connection with the target machine
      void removeDir​(java.lang.String dirPath)
      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 localStdin, java.lang.String remoteStdin)
      Transfer file localStdin to remoteStdin.
    • Method Detail

      • executeCommand

        Entry executeCommand​(java.lang.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​(java.lang.String cmd,
                             java.lang.String[] args,
                             java.lang.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

        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.
        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​(java.lang.String localStdin,
                          java.lang.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​(java.lang.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​(java.lang.String enc)
        Sets encoding for the command arguments before executing the actual command
        Parameters:
        enc - encoding to be used