Solaris Common Desktop Environment: Advanced User's and System Administrator's Guide

Building the Execution String for a COMMAND Action

The minimum requirements for a COMMAND action are two fields—ACTION and EXEC_STRING.

ACTION action_name
 {
     EXEC_STRING execution_string
 }

The execution string is the most important part of a COMMAND action definition. It uses syntax similar to the command line you would execute in a Terminal window but includes additional syntax for handling file and string arguments.

General Features of Execution Strings

Execution strings may include:

Action Arguments

An argument is information required by a command or application for it to run properly. For example, consider the command line you could use to open a file in Text Editor:

dtpad filename

In this command, filename is a file argument of the dtpad command.

Actions, like applications and commands, can have arguments. There are two types of data that a COMMAND action can use:

Using Shells in Execution Strings

The execution string is executed directly, rather than through a shell. However, you can explicitly invoke a shell in the execution string.

For example:

EXEC_STRING				\
 		/bin/sh -c \
 		'tar -tvf %(File)Arg_1% 2>&1 | \${PAGER:-more};\
 		echo "\\n*** Select Close from the Window menu to close ***"'

Name or Absolute Path of the Executable

If your application is located in a directory listed in the PATH variable, you can use the simple executable name. If the application is elsewhere, you must use the absolute path to the executable file.

Creating an Action that Uses No Arguments

Use the same syntax for the EXEC_STRING that you would use to start the application from a command line.

Examples

Creating an Action that Accepts a Dropped File

Use this syntax for the file argument:

%Arg_n%

or

%(File)Arg_n%

(File) is optional, since arguments supplied to Arg_n are assumed (by default) to be files. (See Interpreting a File Argument as a String for use of the %(String)Arg_n% syntax.)

This syntax lets the user drop a data file object on the action icon to start the action with that file argument. It substitutes the nth argument into the command line. The file can be a local or remote file.

Examples

Creating an Action that Prompts for a File Argument

Use this syntax for the file argument:

%(File)"prompt"% 

This syntax creates an action that displays a prompt for a file name when the user double-clicks the action icon.

For example, this execution string displays a dialog box that prompts for the file argument of the wc -w command:

EXEC_STRING wc -w %(File)"Count words in file:"%

Creating an Action that Accepts a Dropped File or Prompts for One

Use this syntax for the file argument:

%Arg_n"prompt"%

or

%(File)Arg_n"prompt"%

This syntax produces an action that:

Creating an Action that Prompts for a Non-File Argument

Use this syntax for the non-file parameter:

%"prompt"%

or

%(String)"prompt"%

(String) is optional, since quoted text is interpreted, by default, as string data. This syntax displays a dialog box that prompts for non-file data; do not use this syntax when prompting for a file name.

For example, this execution string runs the xwd command and prompts for a value to be added to each pixel:

EXEC_STRING xwd -add %"Add value:"% -out %Arg_1"Filename:"%

Interpreting a File Argument as a String

Use this syntax for the argument:

%(String)Arg_n%

For example, this execution string prints a file with a banner containing the file name, using the command lp -tbanner filename.

EXEC_STRING lp -t%(String)Arg_1% %(File)Arg_1"File to print:"%

Providing Shell Capabilities in an Action

Specify the shell in the execution string:

/bin/sh -c 'command'
/bin/ksh -c 'command'
/bin/csh -c 'command'

Examples

Creating COMMAND Actions for Multiple File Arguments

There are three ways for actions to handle multiple file arguments:

Creating an Action for Non-Interchangeable Arguments

Use one of the following syntax conventions:

Creating an Action with Interchangeable File Arguments

Use one of the following syntax conventions:

Examples

Creating an Action for Multiple Dropped Files

To accept multiple dropped file arguments and execute a command line in the form:

command file 1 file 2

use the syntax:

%Args%

Examples