Exec Command
Execute arbitrary system calls and replaces templated environment variables with Keeper vault secrets
exec command
Use the ksm exec command to substitute environment variables with vault secrets.
Parameters:
System call or script to run with replaced environment variables
format: ksm exec -- <SYSTEM CALL OR SCRIPT>
Example Linux bash script
#!/bin/bash
# Bash script that pulls Keeper secrets
connect_db() {
echo "Database Password:" $DB_PASSWORD
}
call_stripe() {
echo "API Key:" $API_KEY
}
connect_db
call_stripeSet two environment variables, then run the script:
Example Windows batch file
Example PowerShell script
Environment Variable Replacement
Environment variables must be templated so that the CLI can find and replace them correctly. See the Keeper Notation documentation for notation query format and capabilities. For example:
Example Shell Script
Below is a Linux bash script example. Before an application is started or a command is run, any environment variables that start with keeper:// will be replaced with secret values from the vault. Make sure to replace XXXX with the Record UID of the secret.
Here's a simple bash script that prints the secrets to the console:
And here's the output from executing the bash script with ksm exec
Last updated

