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 and passphrases and print Process Server parameter values.

Note: For installation instructions, see jtool.

Syntax

Copy
jecho [-h|-?|-help] [-l <loglevel>] [-f <logfile>] [-j|-job-context] [-log]
      [-log-with-level <loglevel>] [<message>] ...

Argument Description
-base64 Echos output encoded in base64.
-f <logfile> Logs to a file instead of stdout.
-fix-pem Fixes newlines in PEM-encoded keys when if they are sent with spaces instead.
-h,-?,-help Shows the help.
-j, -job-context Gets the environment from the job context.
-l <loglevel> Sets the logging level.
-log Write to stdout in standard log format.
-log-with-level <loglevel> info Sets the log level for the -log option.
-n Suppresses 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, so in such interpreters you should enclose it in single quotes.

Copy
jtool echo -j '${DataRootDirectory}'

You can use this outside of job-context, but only environment variables are available.

Note: jecho expects a correctly escaped environment variable name for your shell. Make sure the shell does not evaluate the variable. Numerous examples are available below.

Decrypting Passwords

jecho can decrypt externally available credential passwords. Use =Credential.getProtectedPassword('MY_ENDPOINT', 'MY_USER') to retrieve the encrypted credential password. Specify the parameter containing the encrypted password using the ${<parameter_name>} syntax. Note that this needs to be appropriately escaped for the shell.

The following examples uses a Process Definition Parameter named P_PASS_PHRASE, containing the encrypted password, using =Credential.getProtectedPassword('MY_ENDPOINT', 'MY_USER').

BASH

Copy
jtool echo -j '${P_PASS_PHRASE}'
export PASS=`jtool echo -j '${P_PASS_PHRASE}'`
echo $PASS

CMD

Copy
jtool echo -j ${P_PASS_PHRASE}
for /f %%i in ('jtool echo -j ${P_PASS_PHRASE}') do SET PASS=%%i
echo %PASS%

PS1 (PowerShell)

Copy
$env:P_PASS_PHRASE = ${P_PASS_PHRASE}
jtool echo -j '${P_PASS_PHRASE}' | Tee-Object -Variable "P_PASS_PHRASE"
Write-Output $P_PASS_PHRASE

Examples

Print a Message

This sample Windows CMD script shows how to log errors in output files. Alternatively, you can use jmessage to create Operator Messages.

Copy
dir g:
if %ERRORLEVEL% 1 jecho "Drive G: not accessible!"

Decrypting PEM Passwords

This example Bash script testa 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.

Copy
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

Here is a sample Windows CMD script for the same thing. Note that the this script does not need to escape ${MY_PASSWORD}.

Copy
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
)

Decrypting Credential Passwords

This CMD example shows how to decrypt a password retrieved from an externally available credential and pipe it to mycommand.

Copy
jecho -j -n "${MyParam}" | mycommand

This BASH example shows how to decrypt a password retrieved from an externally available credential and pipe it to mycommand.

Copy
jtool echo -j -n '${MyPassword}' | mycommand

ListProcess Server Parameters and Environment Variables with Values

This CMD example shows how to list all Process Server parameters and environment variables with values. It specifies tokens=* in the second loop because the value may contain spaces or tabs.

Copy
for /f  %%i in ('jtool echo -j "${LISTALL}"') do (
for /f "tokens=*" %%j IN ('jtool echo -j "${%%i}"') DO echo %%i=%%j
)

Here is the same example in BASH.

Copy
for i in $(jtool echo -j '${LISTALL}')
do
  echo "$i = $(jtool echo -j '${'$i})"
done

Here is the same example in PowerShell.

Copy
foreach ($i in $(jtool echo -j '${LISTALL}'))
{
  $i + "=" + $(jtool echo -j `$`{$i`})
}

Generating Base64-Encoded Credentials for Authorization Headers

The following examples show how to generate Base64-encoded credentials for authorization headers.

Copy
CREDS=$(jecho -base64 "${Username}:${Password}")
Copy
for /f %%i in ('jecho -base64 "%Username%:%Password%"') do set CREDS=%%i