Class ExecUtil

java.lang.Object
org.openhab.core.io.net.exec.ExecUtil

@NonNullByDefault public class ExecUtil extends Object
Some common methods to execute commands on command line.
Author:
Pauli Anttila - Initial contribution, Kai Kreuzer - added exception logging, Connor Petty - replaced delimiter usage with argument array
  • Constructor Details

    • ExecUtil

      public ExecUtil()
  • Method Details

    • executeCommandLine

      public static void executeCommandLine(String... commandLine)

      Executes commandLine.

      A possible IOException gets logged but no further processing is done.

      Parameters:
      commandLine - the command line to execute
    • executeCommandLineAndWaitResponse

      public static @Nullable String executeCommandLineAndWaitResponse(@Nullable Duration timeout, String... commandLine)

      Executes commandLine and return its result.

      A possible IOException gets logged but no further processing is done.

      Parameters:
      timeout - the max time to wait for a process to finish, null to wait indefinitely
      commandLine - the command line to execute
      Returns:
      response data from executed command line or null if a timeout or error occurred