Class SystemCommandExecutor

java.lang.Object
org.forester.util.SystemCommandExecutor

public class SystemCommandExecutor extends Object
  • Constructor Details

    • SystemCommandExecutor

      public SystemCommandExecutor(List<String> command_information)
      Pass in the system command you want to run as a List of Strings, as shown here: List commands = new ArrayList(); commands.add("/sbin/ping"); commands.add("-c"); commands.add("5"); commands.add("www.google.com"); SystemCommandExecutor commandExecutor = new SystemCommandExecutor(commands); commandExecutor.executeCommand(); Note: I've removed the other constructor that was here to support executing the sudo command. I'll add that back in when I get the sudo command working to the point where it won't hang when the given password is wrong.
      Parameters:
      command_information - The command you want to run.
  • Method Details

    • isExecuteableFile

      public static boolean isExecuteableFile(File path_to_cmd_f)
    • executeCommand

      public int executeCommand() throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • getStandardErrorFromCommand

      public StringBuilder getStandardErrorFromCommand()
      Get the standard error (stderr) from the command you just exec'd.
    • getStandardOutputFromCommand

      public StringBuilder getStandardOutputFromCommand()
      Get the standard output (stdout) from the command you just exec'd.