Class BashHelper

java.lang.Object
com.pnfsoftware.jeb.util.base.BashHelper

public class BashHelper extends Object
Helper to interact with bash terminals.

This helper can be used to retrieve bash environment variables (variables not defined system-wide).

  • Constructor Details

    • BashHelper

      public BashHelper()
  • Method Details

    • env

      public static String env(String varname)
      Get an environment variable provided within a Bash interactive session.
      Parameters:
      varname - variable name
      Returns:
      the value, or null on error or if none is defined
    • exec

      public static String exec(long timeoutMs, String cmd)
      Run a Bash interactive command.
      Parameters:
      timeoutMs - timeout in milliseconds, must be equal or greater than zero
      cmd - the bash command: bash -ic <command>
      Returns:
      the command result, null on error or if the execution timed-out