Command Resource

Undraw Environment

Command Resource

About

A command is the runtime data resource of a file system that represents a operating system command.

It supports as executable:

Howto

Data URI

Example of a command resource runtime data uri

(hello-world.sh@cd)@tmp

A command runtime data uri has an executionConnection that

Script Execution

With a Shebang

Scripts are automatically executable if they contain a shebang (ie the path and argument of their interpreter)

The shebang is the first line of a script

  • starting with a #!
  • that defines the path and argument of their interpreter.

Example with the bash script called hello-world located in the home directory with the shebang #!/usr/bin/env bash

#!/usr/bin/env bash
echo "Hello World"

This script will be executed:

  • with as operating system command: /usr/bin/env
  • and 2 arguments
    • bash
    • /home/tabulify/hello-world
/usr/bin/env bash /home/tabulify/hello-world

Without a Shebang

Without a shebang, you need to use the binary executable as executable and defines the path in its arguments.

Example: This is the same example as above calling the same bash script but with the binary as executable.

kind: command
spec:
  # bin being a connection defined with the directory /usr/bin
  data-uri: (env@bin)@tmp
  data-def:
     arguments:
       - bash
       - /home/tabulify/hello-world

Manifest

Example of command kind manifest for a command

  • with the fictional script hello-world script called
  • with the argument World
kind: command
spec:
  # a runtime data uri
  data-uri: '(hello-world@home)@tmp'
  data-def:
     # A list of arguments passed to the command
     arguments:
       - 'World' # first argument
       - .... # second argument
     # The location of stdout (Default value)
     stdout-data-uri: 'execute/${execution_start_time}-${executable_logical_name}.log@tmp'
     # The location of stderr (Default value)
     stderr-data-uri: 'execute/${execution_start_time}-${executable_logical_name}-err.log@tmp'
     # buffer size used when writing to the std files
     std-buffer-size: 8192
     # The location of the result returned
     # Default to the stdout value if not specified
     # but you may specify any other value if your script output is data elsewhere
     result-data-uri: 'hello-results.log@tmp'
     # time-out in duration
     time-out: '60s'
     # working directory
     working-directory: '/tmp'

Attributes

All attributes are optional.

Attributes Description
arguments Empty List A list of arguments passed to the command
stdout-data-uri See stdout A template data uri that specifies the location of stdout
stderr-data-uri See stderr A template data uri that specifies the location of stderr
std-buffer-size 8192 The buffer size in bytes when writing to the standard stream (stdout and stderr)
result-data-uri See result An optional template data uri that specifies the location of the result data path returned
time-out 60s A timeout in duration format
working-directory the execution connection directory The working directory of the execution

A command inherit also all common attributes

Stdout Data Uri

stdout-data-uri defines where the standard output of the execution should be stored.

It's a template data uri that accepts

By default, the standard output (stdout) is stored at the runtime temporary connection with the following value:

execute/${execution_start_time}-${executable_logical_name}.log@tmp

StdErr Data Uri

stderr-data-uri defines where the standard error of the execution should be stored.

It's a template data uri that accepts

By default, the standard error (stderr) is stored at the runtime temporary connection with the following value:

execute/${execution_start_time}-${executable_logical_name}-err.log@tmp

Result Data Uri

By default, the returned data resource is the standard output.

If your script outputs logs in standard output and creates data in another location, you may specify it with the result-data-uri.

Working Directory

The working directory specifies where the command execution will take place.

By default, it's the directory of the execution connection.

For instance:

With the working-directory attribute, you can set another value.




Related HowTo
Undraw Environment
How to create a CSV dynamically with a script?

This howto will show you how you can create any resource dynamically with a script. In this example, we will create a CSV but you can create any type of resource on the fly. You should have followed...
Undraw Environment
How to execute a bash script ?

This howto shows you how to execute a bash script against the local file system. The bash script that will be executed is: a simple hello world sample application that accepts optionally 1 argument...

Task Runner