63. run
Prev | Chapter 6. Commands written in the Java™ programming language | Next

## 63. run

Parameter syntax:

    [ [ '[Windows]'|'[Unix]'|'[GenericUnix]'|'[Mac]' ]? command_line ]?

Executes external command line specified by its parameter. If no parameter is specified, prompts user to input a command line.

Returns output of executed command line (that is, what is printed on `stdout` in C/Unix parlance).

The command line is executed using `/bin/sh` on Unix and using `cmd.exe` on Windows (this means that ``run`` will not work on Windows 9x or Windows ME).

Specified command line may reference helper applications declared using the Preferences dialog box, Helper Applications section.

Command line may contain variables which are substituted with their values prior to command execution:

%F

  File name of a temporary file containing a copy of the selection. This temporary file is created in the same directory than the directory containing the document being edited.

  - If a single element is selected, this element is saved in a DTD-less XML file, having a `.xml` extension, encoded using UTF-8.

  - If several nodes are selected, the parent element of these nodes are saved in a DTD-less XML file, having a `.xml` extension, encoded using UTF-8.

  - If there is a text selection or a single textual node is selected, the selected text is saved in a text file, having a `.txt` extension, encoded using the native encoding of the platform.

  - If there is no explicit selection, the whole document is saved in a XML file, possibly having a DTD or XML-Schema, having same extension than document being edited, encoded using UTF-8.

%f

  Same as `%F` except that it is a `file:` URL.

%d

  URL of the document being edited.

%D

  File name of the document being edited.

  If this variable needs to be sustituted and if document being edited is not stored on the local file system (example: `http://dav.acme.com/docs/mydoc.xml`), command run cannot be executed.

The "`%`" character can be escaped using "`%%`". The above variables can be specified as `%{F}`, `%{f}`, `%{d}`, `%{D}` if it helps.

If the platform option (that is, `[Windows]`, `[Unix]`, `[GenericUnix]` or `[Mac]`) is not specified, the command line is executed whatever is the platform running XXE.

If the platform option is specified, the command line is executed only if the platform running XXE matches the value of this options:

[Windows]

  Any version of Windows.

[Mac]

  Mac OS X.

[GenericUnix]

  A Unix which is not Mac OS X (Linux, Solaris, etc).

[Unix]

  [GenericUnix] or [Mac].

Examples:

    run date
    run expand %F
    run emacs "%D"
    run helper(text/plain) "%D"
    run "C:\Program Files\Info ZIP\zip.exe" -r all.zip "C:\temp\misc"

    <choice>
      <command name="run" parameter='[Windows] notepad "%D"' />
      <command name="run" parameter='[Unix] emacs "%D"' />
    </choice>

Prev | Up | Next
62. replaceText | Home | 64. search