MULTEXT - Document MQL2. SgmlQL reference/Operators.
Executing shell commands

Commands given between backquotes (` ... `) are executed in a Bourne shell. The standard output of the command is returned in string1

Prototype

string <-- ` string2 `

Interactive examples

  • element DATE content: `date`;
  • <DATE>
    Sun Jun 16 18:12:50 WET DST 1997
    </DATE>
  • global $files = split (`ls`);
  • text($files, "\n");
    countries.sgml
    dates.sgml
    exemple-DTD.sgml
    myfile-ces.sgml
    
    select
      if
        gi(first within file $f) ne CESHEADER
      then
        "Warning: '" . $f . "' has no header\n"
    from
      $f in $files
    ;
    Warning: 'countries.sgml' has no header
    Warning: 'dates.sgml' has no header
    Warning: 'exemple-DTD.sgml' has no header

    Example as a script

    # put the directory content in list $files
    
    global $files = split(`ls -l *.sgml`);
    
    # for each file, output an element with
    # 'filename' in content, and
    # 'mode', 'owner' and 'group' in attributes
    
    element FILELIST
      attr: DIRECTORY = `pwd`
      content: (
        select (
          let
            $s = split($l, " +")
          in (
            element FILE
              attr: {
                MODE  = $s[1],
                OWNER = $s[3],
                GROUP = $s[4]
              }
              content: $s[9]
          )
        )
        from
          $l in $files
    )
    ;
    

    Result:

    <FILELIST DIRECTORY="/MtSgmlQL/examples">
    <FILE MODE="-rw-r--r--" OWNER="sgmlql" GROUP="multext">
    countries.sgml
    </FILE><FILE MODE="-rw-r--r--" OWNER="sgmlql" GROUP="multext">
    dates.sgml
    </FILE><FILE MODE="-rw-r--r--" OWNER="sgmlql" GROUP="multext">
    exemple-DTD.sgml
    </FILE><FILE MODE="-rw-r--r--" OWNER="sgmlql" GROUP="multext">
    myfile-ces.sgml
    </FILE></FILELIST>
    
    




    | Top | Next | SgmlQL reference | LPL/CNRS | MULTEXT

    Copyright © Centre National de la Recherche Scientifique, 1997.