Skip navigation links

Package com.palantir.giraffe.command

Provides classes and interfaces for local and remote command execution.

See: Description

Package com.palantir.giraffe.command Description

Provides classes and interfaces for local and remote command execution.

Executable commands are represented by Command objects. Each Command is associated with an ExecutionSystem that can execute the command on a local or remote host. Each ExecutionSystem is associated with an ExecutionSystemProvider, which is responsible for creating systems for different hosts using the same connection method, for instance SSH.

Most operations on Commands are defined in Commands. As an example:

 Command ls = Commands.get("ls", "-a", "-l");
 CommandResult result = Commands.execute(ls);
 
This executes the "ls" command on the local system, returning an object containing the exit code and output.

Local Execution

The local execution system is accessed using the ExecutionSystems.getDefault() method. There is exactly one instance of the local execution system and it cannot be closed. Because the local execution system is created automatically, it does not accept an environment map for configuration. Instead, the following system properties modify the behavior of the system:

PropertyDescription
giraffe.command.local.envWhitelist A comma-separated list of variable names to keep when creating process environments. If set, all environment variables not in this whitelist will be removed from the default environment of new processes.

When using Giraffe in certain applications, such as servers or similar long-lived services, the application processes is started with environment variables that should not be visible to command processes and may even prevent these processes from executing correctly. Setting this property allows users to create a well-defined default environment for command execution.

Skip navigation links