Class ExecUtil


  • public class ExecUtil
    extends Object
    Some common methods to execute commands on command line.
    Author:
    Pauli Anttila - Initial contribution, Kai Kreuzer - added exception logging
    • Field Detail

      • CMD_LINE_DELIMITER

        public static final String CMD_LINE_DELIMITER
        Use this to separate between command and parameter, and also between parameters.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExecUtil

        public ExecUtil()
    • Method Detail

      • executeCommandLine

        public static void executeCommandLine​(String commandLine)

        Executes commandLine. Sometimes (especially observed on MacOS) the commandLine isn't executed properly. In that cases another exec-method is to be used. To accomplish this please use the special delimiter ' @@'. If commandLine contains this delimiter it is split into a String[] array and the special exec-method is used.

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

        Parameters:
        commandLine - the command line to execute
      • executeCommandLineAndWaitResponse

        public static String executeCommandLineAndWaitResponse​(String commandLine,
                                                               int timeout)

        Executes commandLine. Sometimes (especially observed on MacOS) the commandLine isn't executed properly. In that cases another exec-method is to be used. To accomplish this please use the special delimiter ' @@'. If commandLine contains this delimiter it is split into a String[] array and the special exec-method is used.

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

        Parameters:
        commandLine - the command line to execute
        timeout - timeout for execution in milliseconds
        Returns:
        response data from executed command line