Global Variables
Introduction
In some cases, you want to be able to reference information that you do not have beforehand. For example, you may want to reference the current user executing the program. You may also need to determine the CPU of the computer that is executing the Prog script.
While it is possible to manually retrieve this information (eg. with the Run Bash Script directive), Proggy offers built-in variables which you can already use.
Here is a list of them:
user | User who is executing the command |
uid | UID of the user who is executing the command |
gid | GID of the user who is executing the command |
homedir | Home directory of the user who is executing the command |
cwd | Current directory where the Prog command is executed |
os | Operating system of the system |
env | Environment variables (see below regarding usage) |
Note: If Proggy is unable to determine the above values, it will return the value of “Unknown”.
Environment Variables
As noted above, you can access your system’s environment variables by using the env
variable.
Let’s say you have an environment variable of MY_PATH
, equaling to ~/mypath
. To access this variable within a Prog command, you can reference env.MY_PATH
. As a Liquid variable, you would type {{ env.MY_PATH }}
.
During testing and development, you may wish to see the full list of environment variables available to you. For this, you can use a Display Text directive and print out all the environment variables using {{ env }}
.
This will print out something like the following, which you can then quickly inspect all available variables:
map[MY_PATH:~/mypath SECRET_KEY:abcdefg123 etc]
In the above example, you see two environment variables set: MY_PATH
and SECRET_KEY
. These can then be referenced as env.MY_PATH
and env.SECRET_KEY
respectively.