jecho, jtool echo
A platform agent tool used to send messages to STDOUT
, similar to the echo
command, with the added benefit of being able to decrypt passwords, passphrases and print process server parameter values.
Syntax
jecho [-h|-?|-help] [-l <loglevel>] [-f <logfile>] [-j|-job-context] [-log]
[-log-with-level <loglevel>] [<message>] ...
Argument | Description |
---|---|
-base64 | Echo output encoded in base64. |
-f <logfile> | Log to file instead of stdout. |
-fix-pem | Fixes newlines in PEM formatted keys when those are sent with spaces instead. |
-h,-?,-help | Show this help and exit. |
-j, -job-context | Run the command in job-context. |
-l <loglevel> | Set the logging level. |
-log | Write to stdout in standard log format. |
-log-with-level <loglevel> INFO | Set loglevel for -log option. |
-n | Suppress newlines, equivalent to echo -n on UNIX. |
<message> | Message text |
Environment Variables and Process Server Parameters
The jecho
command allows you to print out process server parameter values and environment variables. The special ${LISTALL}
variable contains a list of all environment variable and process server parameters. Any process server parameter that has remote
set to true
can be accessed in this way. Note that these must use the ${<name>}
syntax in all interpreters and you must ensure that the interpreter does not attempt to evaluate them. Note that a number of interpreters including Bash, KSH, CSH, and PowerShell will attempt to evaluate the variable, you should enclose it in single quotes:
jtool echo -j '${DataRootDirectory}'
This can be used outside of job-context
, however, only environment variables are available.
note
jecho
expects a correctly escaped [environment] variable name for your shell, you must ensure the shell does not evaluate the variable. Numerous examples are available below.
Decrypting Passwords
Jecho can decrypt externally available credential passwords. You use =Credential.getProtectedPassword('MY_ENDPOINT', 'MY_USER')
to retrieve the encrypted credential password. You specify the parameter containing the encrypted password using the ${<parameter_name>}
syntax; this needs to be appropriately escaped for the shell.
The following Bash example needs a process definition parameter named MyPassword
containing the encrypted password, using =Credential.getProtectedPassword('MY_ENDPOINT', 'MY_USER')
for example:
jtool echo -j -n '${MyPassword}'
Example
Print a Message
An example Microsoft Windows CMD script to show how you can log errors in output files. Alternatively, you use jmessage to create operator messages.
dir g:
if errorlevel 1 jecho "Drive G: not accessible!"
Decrypting PEM Passwords
An example Bash script to test a PEM key stored in a parameter. If the PEM key is stored in a credential, you can use =Credential.getProtectedPassword('MY_ENDPOINT', 'MY_USER')
to retrieve it, the jtool echo
command will decrypt the password.
jtool echo -j -out -fix-pem '${MY_PASSWORD}' > my_password.txt
if grep -q - '--BEGIN' my_password.txt
then
echo "Testing for PEM key validity"
openssl rsa -modulus -in my_password.txt
fi
An example Windows BATCH (CMD) example of the above, note that the Windows Batch (CMD) script does not need to escape the ${MY_PASSWORD}
.
jtool echo -j -fix-pem ${MY_PASSWORD} > my_password.txt
findstr /C:"-----BEGIN" my_password.txt 2>&1 >nul && (
echo "Testing for PEM key validity"
openssl.exe rsa -modulus -in my_password.txt
)
Decrypt Credential Passwords
A CMD example to decrypt a password retrieved from an externally available credential and pipe it to mycommand
:
jecho -j -n "${MyParam}" | mycommand
A Bash example to decrypt a password retrieved from an externally available credential and pipe it to mycommand
:
jtool echo -j -n '${MyPassword}' | mycommand
List All Process Server Parameters and Environment Variables with values
Windows CMD example:
for /f %%i in ('jtool echo -j "${LISTALL}"') do (
for /f "tokens=*" %%j IN ('jtool echo -j "${%%i}"') DO echo %%i=%%j
)
note
In the example above, we specify tokens=*
in the second loop as the value may contain spaces and or TAB characters.
In Bash
for i in $(jtool echo -j '${LISTALL}')
do
echo "$i = $(jtool echo -j '${'$i})"
done
In PowerShell
foreach ($i in $(jtool echo -j '${LISTALL}'))
{
$i + "=" + $(jtool echo -j `$`{$i`})
}
Generate base64 encoded credentials for Authorization Headers
CREDS=$(jecho -base64 "${Username}:${Password}")
for /f %%i in ('jecho -base64 "%Username%:%Password%"') do set CREDS=%%i