Using environment variables within a script

In Kognitio, every external script that is invoked (i.e. every thread) is run in a specified environment and each has a particular set of environment variables (e.g. Python’s will be different from R’s).

Environment variables can relate to the hardware the invocation is running on, the operating system, the Kognitio software (e.g. the software version) and to the external script invocation itself.

All the environment variables pertaining to Kognitio are prefixed with WX2_.

Example: bash script returning list of Kognitio environment variables

The following bash inline external script returns a full list of its available environment variables.

EXTERNAL SCRIPT USING ENVIRONMENT bash
SENDS(res varchar(100))
LIMIT 1 THREADS
SCRIPT S'EOF(
#!/bin/sh
printenv | grep WX2
)EOF'
;

A selection of these are explained below:

  • WX2_SESSION - the Kognitio session ID which called the script

  • WX2_TNO - the transaction number which called the script

  • WX2_STATEMENT - the statement number within the transaction which called the script

  • WX2_USERID - the user ID which called the script