Q100679: How to get environment variable values

Follow

SUMMARY

The following article details how to get environment variables values on each platform or inside Foundry applications. Environment variables are dynamic-named values which can be used to alter the behaviour of a process that uses them.


MORE INFORMATION

Below are instructions for how to get an environment variable value which has been set on each platform or from within a Foundry application:
Windows
1) Select Start and search for Command Prompt.
2) In the Command Prompt window, enter echo %VARIABLE%, changing VARIABLE with the name of your environment variable:
Linux and macOS
1) Launch Terminal or a shell.
2) Run the command echo $VARIABLE, changing VARIABLE with the name of your environment variable:
Inside Applications

 Nuke

• Press X in the Node Graph, check that TCL is enabled, and enter:

getenv <VARIABLE>

VARIABLE should be replaced by the environment variable you're interested in. For example, by default  NUKE_TEMP_DIR on Windows returns: C:/Users/<userName>/AppData/Local/Temp/nuke

 

All Applications

• Open the Script Editor/Python Console/Python tab and enter:

import os
print(os.environ["VARIABLE"])

VARIABLE should be replaced by the environment variable you're interested in. 

 



FURTHER READING

More information about handling environment variables can be found here:

Q100015: How to set environment variables

Q100017: How to list environment variables

Q100127: How to delete or unset environment variables

 

    We're sorry to hear that

    Please tell us why