Interface CommandExecutor
- All Known Implementing Classes:
LocalCommandExecutor, SshCommandExecutor
public interface CommandExecutor
Abstraction for command execution that can be implemented for different contexts.
This interface allows the same action implementation to work in different execution environments:
SshCommandExecutor- Executes commands on remote nodes via SSHLocalCommandExecutor- Executes commands on the local machine
- Since:
- 2.15.0
- Author:
- devteam@scivicslab.com
-
Method Summary
Modifier and TypeMethodDescriptionExecutes a command and returns the result.execute(String command, Node.OutputCallback callback) Executes a command and returns the result with output callback.executeSudo(String command) Executes a command with sudo privileges.executeSudo(String command, Node.OutputCallback callback) Executes a command with sudo privileges and output callback.Gets a short identifier for this executor (e.g., hostname).
-
Method Details
-
execute
Executes a command and returns the result.- Parameters:
command- the command to execute- Returns:
- the result of command execution
- Throws:
IOException- if command execution fails
-
execute
Executes a command and returns the result with output callback.- Parameters:
command- the command to executecallback- the callback for real-time output (may be null)- Returns:
- the result of command execution
- Throws:
IOException- if command execution fails
-
executeSudo
Executes a command with sudo privileges.- Parameters:
command- the command to execute with sudo- Returns:
- the result of command execution
- Throws:
IOException- if command execution fails or SUDO_PASSWORD is not set
-
executeSudo
Executes a command with sudo privileges and output callback.- Parameters:
command- the command to execute with sudocallback- the callback for real-time output (may be null)- Returns:
- the result of command execution
- Throws:
IOException- if command execution fails or SUDO_PASSWORD is not set
-
getIdentifier
Gets a short identifier for this executor (e.g., hostname).- Returns:
- the identifier string
-