Class TerminalUtility

java.lang.Object
io.github.eggy03.dmidecode.utility.TerminalUtility

public class TerminalUtility extends Object
A utility class that provides a way to launch a terminal session

Mostly for internal use

Since:
0.1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NonNull String
    executeCommand(@NonNull String command, long timeoutSeconds)
    Launches a standalone terminal session, executes the given command and returns the result

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      private static final org.slf4j.Logger log
  • Constructor Details

    • TerminalUtility

      private TerminalUtility()
  • Method Details

    • executeCommand

      public static @NonNull String executeCommand(@NonNull String command, long timeoutSeconds)
      Launches a standalone terminal session, executes the given command and returns the result
      Parameters:
      command - The command/script to be executed in the terminal
      timeoutSeconds - Time in seconds after which the session will be force stopped
      Returns:
      The result of the command executed
      Throws:
      TerminalExecutionException - When the process is killed pre-maturely upon reaching the timeout or when the command yields an error, or when the terminal cannot be accessed.
      IllegalArgumentException - If the provided timeout is in the negative