Library: System call (OMSYSOUT legacy)

Returns: A source containing the standard output and standard error from 'Command'.

define external string source function SYSOUTSystemCall
   value string command
   input-from value string command-input optional
   in-directory value string directory optional

Argument definitions

The command to be executed, containing any required parameters.
A stream which is to be written to command's standard input.
The current working directory to be used for the external program.


This function is used to execute the external program specified in 'command'.

If 'command-input' is specified, then that is streamed to command's standard input.

If 'directory' is specified, then the given path is used as the current working directory for the external program; otherwise, the external program inherits the current working directory from the OmniMark process.

If 'directory' is specified, it is recommended to use an absolute path to the program in 'command' to avoid any ambiguity.

This function returns a source containing the standard output and standard error from 'command', which can then be used by repeat scan, do scan, set, submit and similar OmniMark keywords.


The following OmniMark program executes an external program called 'hello'. Two lines of input are streamed to its standard input, containing '2' and 'OmniMark'. The output from 'hello' is then scanned and echoed to the screen.

  include ""
  global stream command initial {'hello'}
  global stream cmd-args initial {'2%nOmniMark%n'}
     repeat scan SYSOUTSystemCall command input-from cmd-args
        match value-start | line-end
        output '<%n'
        match any-text*=>line
        output '<<!%g(line)>%n'
        match any

This program will copy the output from the external program named "hello", and surround each line of output with angle brackets.

The following example can be used on a UNIX system to execute the command "ls" and output the filenames and dates that it finds:

  include ""
  global stream command initial {'ls -lF'}
     repeat scan SYSOUTSystemCall command
        match any-text{10} white-space+ digit+ white-space+ any++ white-space+
           any++ white-space+ digit+ white-space any-text{12}=>filedate
           white-space any-text+=>filename '%n'
        output 'date: %g(filedate) name: %g(filename)%n'
        match any-text* '%n'

Other Library Functions