Package org.forester.util
Class SystemCommandExecutor
- java.lang.Object
-
- org.forester.util.SystemCommandExecutor
-
public class SystemCommandExecutor extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SystemCommandExecutor(java.util.List<java.lang.String> command_information)Pass in the system command you want to run as a List of Strings, as shown here: Listcommands = 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intexecuteCommand()java.lang.StringBuildergetStandardErrorFromCommand()Get the standard error (stderr) from the command you just exec'd.java.lang.StringBuildergetStandardOutputFromCommand()Get the standard output (stdout) from the command you just exec'd.static booleanisExecuteableFile(java.io.File path_to_cmd_f)
-
-
-
Constructor Detail
-
SystemCommandExecutor
public SystemCommandExecutor(java.util.List<java.lang.String> command_information)
Pass in the system command you want to run as a List of Strings, as shown here: Listcommands = 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 Detail
-
isExecuteableFile
public static boolean isExecuteableFile(java.io.File path_to_cmd_f)
-
executeCommand
public int executeCommand() throws java.io.IOException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
getStandardErrorFromCommand
public java.lang.StringBuilder getStandardErrorFromCommand()
Get the standard error (stderr) from the command you just exec'd.
-
getStandardOutputFromCommand
public java.lang.StringBuilder getStandardOutputFromCommand()
Get the standard output (stdout) from the command you just exec'd.
-
-