utils: honor custom timeout for script execution for exit value

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2024-07-08 11:35:28 +05:30
parent d99cf93d7c
commit b080215c08

View File

@ -660,8 +660,8 @@ public class Script implements Callable<String> {
return executable; return executable;
} }
private static Script getScriptForCommandRun(String... command) { private static Script getScriptForCommandRun(long timeout, String... command) {
Script s = new Script(command[0], 0); Script s = new Script(command[0], timeout);
if (command.length > 1) { if (command.length > 1) {
for (int i = 1; i < command.length; ++i) { for (int i = 1; i < command.length; ++i) {
s.add(command[i]); s.add(command[i]);
@ -670,12 +670,16 @@ public class Script implements Callable<String> {
return s; return s;
} }
private static Script getScriptForCommandRun(String... command) {
return getScriptForCommandRun(0, command);
}
public static String executeCommand(String... command) { public static String executeCommand(String... command) {
return runScript(getScriptForCommandRun(command)); return runScript(getScriptForCommandRun(command));
} }
public static int executeCommandForExitValue(long timeout, String... command) { public static int executeCommandForExitValue(long timeout, String... command) {
return runScriptForExitValue(getScriptForCommandRun(command)); return runScriptForExitValue(getScriptForCommandRun(timeout, command));
} }
public static int executeCommandForExitValue(String... command) { public static int executeCommandForExitValue(String... command) {