java.lang.Object
org.nuxeo.ecm.platform.commandline.executor.service.executors.ShellExecutor
All Implemented Interfaces:
Executor

public class ShellExecutor extends Object implements Executor
Default implementation of the Executor interface. Use simple shell exec.
  • Field Details

    • PIPE_COUNT

      protected static final AtomicInteger PIPE_COUNT
    • COMMAND_SPLIT

      protected static final Pattern COMMAND_SPLIT
      Used to split the contributed command, NOT the passed parameter values.
    • useTimeout

      protected final boolean useTimeout
    • DEFAULT_TIMEOUT_S

      public static final int DEFAULT_TIMEOUT_S
      See Also:
  • Constructor Details

    • ShellExecutor

      public ShellExecutor(boolean useTimeout)
  • Method Details

    • exec

      Description copied from interface: Executor
      No exception is thrown but the returned ExecResult contains everything about the command execution, including an optional exception.

      The execution duration is time boxed by the lower value of the command description timeout or the transaction TTL, the TTL must be greater than 5s to avoid transaction timeout.

      Specified by:
      exec in interface Executor
      Parameters:
      cmdDesc - Command to run. Cannot be null.
      params - Parameters passed to the command. Cannot be null.
      env - Environment context (variable and working directory)
      Returns:
      Result of the execution
    • getScopedSpan

      protected io.opencensus.common.Scope getScopedSpan(String name, String command)
    • exec1

      protected ExecResult exec1(CommandLineDescriptor cmdDesc, CmdParameters params, EnvironmentDescriptor env) throws IOException
      Throws:
      IOException
    • getTimeout

      protected int getTimeout(CommandLineDescriptor cmdDesc) throws TimeoutException
      Throws:
      TimeoutException
    • createProcessBuilder

      protected ProcessBuilder createProcessBuilder(List<String> command, EnvironmentDescriptor env)
    • getReturnCode

      protected int getReturnCode(List<Process> processes)
    • pipe

      @Deprecated(since="11.1") public static Thread pipe(InputStream in, OutputStream out)
      Deprecated.
      since 11.1, seems unused
      Returns a started daemon thread piping bytes from the InputStream to the OutputStream.

      The streams are both closed when the copy is finished.

      Since:
      7.10
    • replaceParams

      public static List<String> replaceParams(String word, CmdParameters params)
      Expands parameter strings in a parameter word.

      This may return several words if the parameter value is marked as a list.

      Since:
      7.10
    • getCommandAbsolutePath

      public static String getCommandAbsolutePath(String command)
      Returns the absolute path of a command looked up on the PATH or the initial string if not found.
      Since:
      7.10