exec

Execute arbitrary commands

One thing to take note of:

  • Any linefeeds will be removed from the command, so this works fine:
    exec:
      command: |
        docker ps
          -all
          --no-trunc
          --quiet
          --size
    
Field NameDescriptionTypeDefault
input-fieldpass the data in this field through the commandstring-
commandA shell command to be executedstring-
resultOffers a way to collect the full output of a command: stdout, stdin, and exit status--

input-field

pass the data in this field through the command

Type: string

Example: pass value of _raw through the tr command and store in out

input:

{"_raw":"hello dolly"}

action:

exec:
    command: tr 'h' 'H'
    input-field: _raw
    result:
      stdout-field: out

output:

{"_raw":"hello dolly","out":"Hello dolly"}

command

A shell command to be executed

without 'result' all output will be discarded; the command is run for its side effect

Type: string

Example: append value of msg to a log file

input:

{"msg":"hello dolly"}

action:

exec:
  command: cat ${msg} >> log.txt

result

Offers a way to collect the full output of a command: stdout, stdin, and exit status

these generated fields are merged with the existing fields

Field NameDescriptionTypeDefault
stdout-fieldField where stdout of command will be storedfield-
stderr-fieldField where stderr of command will be storedfield-
status-fieldField where exit staus of command will be storedfield-

stdout-field

Field where stdout of command will be stored

The output will be discarded if this field is not specified

Type: field

Example

input:

{"one":1,"two":2}

action:

exec:
  command: echo ${one} and ${two}
  result:
    stdout-field: stdout

output:

{"one":1,"two":2,"stdout":"1 and 2"}

stderr-field

Field where stderr of command will be stored

Type: field

Example

input:

{"one":1,"two":2}

action:

exec:
  command: "echo \"return with an error\" 1>&2 && false"
  result:
    stderr-field: stderr

output:

{"one":1,"two":2,"stderr":"return with an error"}

status-field

Field where exit staus of command will be stored

Type: field

Example

input:

{"one":1,"two":2}

action:

exec:
  command: echo ${one} and ${two}
  result:
    status-field: status

output:

{"one":1,"two":2,"status":0}