Examples

Simple

rules:
  - name: Execute some commands
    on:
      path: /commands/1
      methods:
        - get
        - post
    run.script: |
        date
        id
        whoami        
    args:
      interpreter: /bin/bash
      timeout: 2

Advanced

rules:
  - name: Execute some more commands
    on:
      path: /commands/2
    run.script: "{{ .Input.Form.Script }}"
    args:
      timeout: 3
    respond:
      on_error:
        body: |
          Your script '{{ .Input.Form.Script }}' has failed with: 
            Stderr: {{ .Action.ErrorBody }}
            Stdout: {{ .Action.SuccessBody }}
          Exit Code: {{ .Action.Code }}          
      on_success:
        body: |
          Your script '{{ .Input.Form.Script }}' returns:
          {{ .Action.SuccessBody }}
          {{ .Action.ErrorBody }}          

  - name: execute python
    on:
      path: /commands/3
    run.script: |
        import platform
        print(platform.python_version())        
      args:
        interpreter: python3

Supported Args

interpreter

Define which interpreter shall execute the script.
Defaults:

  • On Linux, system default shell, usually sh.
  • On Windows: powershell taken from the path. Usually this resolves to PowerShell 5. Interpreters ending in powershell or pwsh are started with the options -NoProfile -NonInteractive.

timeout

A timeout (integer, seconds) after which the script and eventually spawned child processes will be killed.

Default: 30 seconds.