swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Other Library Functions  
function  

SYSOUTSystemCall

 
 

Library: System call (OMSYSOUT legacy)
Include: omsysout.xin
Return type: String source

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


Declaration

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

Argument definitions

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


Purpose

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.

Example:

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 "omsysout.xin"
  global stream command initial {'hello'}
  global stream cmd-args initial {'2%nOmniMark%n'}
  
  process
     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
     again

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 "omsysout.xin"
  global stream command initial {'ls -lF'}
  
  process
     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'
     again

      Other Library Functions
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.