Setting an environment variable

From ARToolworks support library

Revision as of 15:39, 4 July 2011 by Philip lamb (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Main Page > ARToolKit Professional > Configuring video capture in ARToolKit Professional > Setting an environment variable

Environment variables can be used to specify configuration information to software.

Contents

Set an environment variable for a single command shell

An environment variable can be set temporarily in a single shell, and will only affect applications launched from that shell. Once the shell is closed (e.g. on a logout or reboot) the environment variable is removed.

Windows

From a "cmd.exe" shell, use the 'set' command:

set NAME=value

Mac OS X / Linux

The syntax varies depending on the shell you're using. First, open a Terminal window, then if using bash (default on Linux and Mac OS X) type:

NAME=VALUE; export NAME

or if using csh or tcsh:

setenv NAME VALUE

Set an environment variable persistently

If you wish to retain an environment variable across shells and reboots etc., use this method:

Windows

First, open the "Environment variables" editor. Its location is a little bit hidden.

Windows XP: Windows 7:

On the left hand side of the window, you will see the environment variable name, and on the right hand side the variables value. Variables can be set either just for the current user or system-wide for all users.

Windows stores system-wide environment variables in the registry, as a string under the key HKLM\System\CurrentControlSet\Control\Session Manager\Environment

Mac OS X

  1. Environment variables can be set from a Terminal window.
  2. From a terminal window, type the following lines, replacing "NAME" with the environment variable name and "VALUE" with its value:
echo "NAME=VALUE; export NAME" >> ~/.profile
echo "setenv NAME VALUE" >> ~/.cshrc
defaults write ~/.MacOSX/environment NAME -string "VALUE"; plutil -convert xml1 ~/.MacOSX/environment.plist

The first line sets the environment for users with users with sh or bash as their shell, the second for users with csh or tcsh as their shell, and the third for programs launched by the Finder (including Xcode).

Linux

  1. Environment variables can be set from a Terminal window.
  2. From a terminal window, type the following lines, replacing "NAME" with the environment variable name and "VALUE" with its value:
echo "NAME=VALUE; export NAME" >> ~/.profile
echo "setenv NAME VALUE" >> ~/.cshrc

The first line sets the environment for users with users with sh or bash as their shell, the second for users with csh or tcsh as their shell.

Views
Personal tools