Chapter 7. Environment Variables

Table of Contents

Max OS X

CSS, like Eclipse RCP and Java programs in general, does not use environment variables. The Eclipse/CSS launcher may use the PATH environment variable to locate a suitable Java runtime, but once CSS is running, all its settings are based on the Eclipse preference system, see Chapter 6, Hierarchical Preferences.

Some CSS tools, however, may start external commands which in turn rely on environment variables. Examples include buttons on an operator interface panel (see Chapter 15, BOY Operator Display) that are configured to react to a mouse click by starting an external command.

Ideally, such external commands can be executed regardless of the current environment settings under which CSS is running. To accomplish this, it is suggested to wrap the actual external command in a script that establishes the required environment:

#!/bin/sh
#
# Example 'start_xy' wrapper script.
# CSS 'BOY' actions could for example use this
# to start an external 'xy' tool.

# Since we cannot know for sure under which environment
# CSS has been started, set all environment variables
# as they are required by the 'xy' tool
export PATH=/usr/local/bin:/usr/bin
export LD_LIBRARY_PATH=/usr/local/xy/lib
export XY_CONFIG_DIR/usr/local/xy/cfg

# Start 'xy' with optional additional parameters
/usr/local/xy/bin/xy -mode=2 -flag=false "$@"

By using such a wrapper script, BOY actions for example can use start_xy something as the external command. Details of required environment variables or command-line flags are hidden inside the wrapper script.

Max OS X

Based on information by Jan Ilavsky, APS

A wrapper script for external applications is especially advantegeous on Mac OS X. While a user may provide certain settings in a ~/.profile file for use in a terminal session, such settings are generally not available inside a Mac OS X application like css.app.

To create environment variables which are then visible within CSS and its externally launched programs, you can start CSS from a script as the following:

#!/bin/sh
#
# Start CSS, including user-specific environment settings
source $HOME/.profile
/Applications/CSS_EPICS_3.1.6/CSS.app/Contents/MacOS/css

This CSS launcher script could then be wrapped by the freely available Platypus.app tool, which can create Mac OS X apps from scripts. In Platypus, configure the app to terminate when done. You may add the CSS icon into the icon view in Platypus. Save as application where convenient and use that to start CSS.app. This provides terminal environment variables to CSS, which are passed to shell programs started by CSS, such as medm.