Solaris Common Desktop Environment: Programmer's Guide

Turning Environment Variables into Command-Line Switches

If your action is not capable of dereferencing the four environment variables, but it is capable of taking corresponding command-line options, this subsection explains how to turn the environment variable values into command-line options.

For example, this is a simple print action that deferences LPDEST:

ACTION Print
{
		ARG_TYPE				data_type
		EXEC_STRING				print_command -d $LPDEST -file %(file)Arg_1% 
}

However, this print action may create unpredictable behavior if LPDEST is not set.

One way to create a Print action that provides proper behavior when variables are not set is to create a shell script that is used by the Print action.

For example, the following action and the script it uses properly handle all four environment variables:

ACTION Print	
{
		ARG_TYPE				data_type
		EXEC_STRING			app_root/bin/envprint %(File)Arg_1%
}

The contents of the envprint script follow:

#!/bin/sh
# envprint - sample print script 
DEST="" 
USERFILENAME=""
REMOVE="" 
SILENT=""  

if [ $LPDEST ] ; then
		DEST="-d $LPDEST" 
fi  

if [ $DTPRINTUSERFILENAME ] ; then
		USERFILENAME="-u $DTPRINTUSERFILENAME" 
fi  

DTPRINTFILEREMOVE=echo $DTPRINTFILEREMOVE | tr "[:upper:]" "[:lower:]"` 
if [ "$DTPRINTFILEREMOVE" = "true" ] ; then
		REMOVE="-e" 
fi  

DTPRINTSILENT=`echo $DTPRINTSILENT | tr

"[:upper:]" "[:lower:]"` if [

"$DTPRINTSILENT" = "true" ] ; then
		SILENT="-s" 
fi  

print_command $DEST $USERFILENAME $REMOVE $SILENT -file $1