Class ShellExecutor

  • All Implemented Interfaces:
    Executor

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

      • COMMAND_SPLIT

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

        protected final boolean useTimeout
    • Constructor Detail

      • ShellExecutor

        public ShellExecutor​(boolean useTimeout)
    • Method Detail

      • exec

        public ExecResult exec​(CommandLineDescriptor cmdDesc,
                               CmdParameters params,
                               EnvironmentDescriptor env)
        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)
      • 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