navigation map

Chapters:
  1: Introduction
  2: Simple example
  3: Invocation
  4: Finer Control
  5: X-Y Plots
  6: Contour Plots
  7: Image Plots
  8: Examples
  9: Gri Commands
  10: Programming
  11: Environment
  12: Emacs Mode
  13: History
  14: Installation
  15: Gri Bugs
  16: Test Suite
  17: Gri in Press
  18: Acknowledgments
  19: License

Indices:
  Concepts
  Commands
  Variables
index.html#Top ListOfGriCommands.html#ListOfGriCommands Gri: `flip' command Gri: `group' command index.html#Top Gri: `group' command

9.3.13: `get env'


`get env \result \environment_variable'

Get the value of an "environment variable" from the unix operating system, and store the result in the indicated synonym. This makes most sense on unix systems (hence the name, patterned after the unix command `getenv'). This command can be useful in making gri programs resistant to changes in data-file locations. Suppose, for example, there is a file called `data', normally in a local directory called `Bravo'. The line `open Bravo/data' will fail if the Bravo directory is moved. But if the name of the datafile is stored in an unix environment variable, `DIR_BRAVO' say, then the gri program will work no matter where the Bravo data are moved, so long as an appropriate environment variable is modified when the data are moved. Example:


get env \dir DIR_BRAVO
if {rpn "\dir" "" ==}
    show "Cannot determine location of the Bravo data,"
    show "which should be stored in the environment"
    show "variable DIR_BRAVO.  You should"
    show "do something like"
    show "export DIR_BRAVO='/data/Bravo/'"
    show "in your ~/.environment file"
    quit
end if
open \dir/data
...

navigation map