Commands ​Commands

yaml
type: "io.kestra.plugin.scripts.shell.commands"
yaml
id: rust_flow
namespace: company.team

tasks:
  - id: rust
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - etl
    containerImage: ghcr.io/kestra-io/rust:latest
    outputFiles:
      - "*.csv"

yaml
id: shell_single_command
namespace: company.team

tasks:
  - id: command
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - 'echo "The current execution is: {{ execution.id }}"'

yaml
id: include_files
namespace: company.team

tasks:
  - id: command
    type: io.kestra.plugin.scripts.shell.Commands
    description: "Only the included `namespaceFiles` get listed"
    namespaceFiles:
      enabled: true
      include:
        - test1.txt
        - test2.yaml
    commands:
      - ls

yaml
id: exclude_files
namespace: company.team

tasks:
  - id: command
    type: io.kestra.plugin.scripts.shell.Commands
    description: "All `namespaceFiles` except those that are excluded will be injected into the task's working directory"
    namespaceFiles:
      enabled: true
      exclude:
        - test1.txt
        - test2.yaml
    commands:
      - ls

yaml
id: shell_generate_files
namespace: company.team

tasks:
  - id: commands
    type: io.kestra.plugin.scripts.shell.Commands
    outputFiles:
      - first.txt
      - second.txt
    commands:
      - echo "1" >> first.txt
      - echo "2" >> second.txt

yaml
id: use_input_file
namespace: company.team

tasks:
  - id: http_download
   type: io.kestra.plugin.core.http.Download
   uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/products.csv

 - id: commands
   type: io.kestra.plugin.scripts.shell.Commands
   commands:
     - cat {{ outputs.http_download.uri }}

yaml
id: input_file
namespace: company.team

inputs:
  - id: text_file
    type: FILE

tasks:
  - id: read_file
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    commands:
      - cat "{{ inputs.text_file }}"

yaml
id: run_php_code
namespace: company.team

tasks:
  - id: commands
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.scripts.runner.docker.Docker
    containerImage: php
    commands:
      - php -r 'print(phpversion());'

yaml
id: create_output_variables
namespace: company.team

tasks:
  - id: commands
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - echo '::{"outputs":{"test":"value","int":2,"bool":true,"float":3.65}}::'

yaml
id: create_counter_metric
namespace: company.team

tasks:
  - id: commands
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - echo '::{"metrics":[{"name":"count","type":"counter","value":1,"tags":{"tag1":"i","tag2":"win"}}]}::'

yaml
id: shell_execute_code
namespace: company.team

inputs:
  - id: dataset_url
    type: STRING
    defaults: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv

tasks:
  - id: download_dataset
    type: io.kestra.plugin.core.http.Download
    uri: "{{ inputs.dataset_url }}"

  - id: c_code
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.scripts.runner.docker.Docker
    containerImage: gcc:latest
    commands:
      - gcc example.c
      - ./a.out
    inputFiles:
      orders.csv: "{{ outputs.download_dataset.uri }}"
      example.c: |
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>

        int main() {
            FILE *file = fopen("orders.csv", "r");
            if (!file) {
                printf("Error opening file!\n");
                return 1;
            }

            char line[1024];
            double total_revenue = 0.0;

            fgets(line, 1024, file);
            while (fgets(line, 1024, file)) {
                char *token = strtok(line, ",");
                int i = 0;
                double total = 0.0;

                while (token) {
                    if (i == 6) {
                        total = atof(token);
                        total_revenue += total;
                    }
                    token = strtok(NULL, ",");
                    i++;
                }
            }

            fclose(file);
            printf("Total Revenue: $%.2f\n", total_revenue);

            return 0;
        }

yaml
id: shell_commands_example
namespace: company.team

tasks:
  - id: generator_shell_commands_task
    type: io.kestra.plugin.scripts.shell.Commands
    outputFiles:
      - out.txt
    commands:
      - echo "Test" > out.txt

  - id: reader_shell_commands_task
    type: io.kestra.plugin.scripts.shell.Commands
    inputFiles:
      generated.txt: "{{ outputs.generator_shell_commands_task.outputFiles['out.txt'] }}"
    commands:
      - >
        echo "Input's absolute path: '{{ workingDir }}/generated.txt'"
Properties
SubType string
SubType string
Default ubuntu
SubType string
Default true
SubType string
Default ["/bin/sh","-c"]
SubType string
Default AUTO
Possible Values
LINUXWINDOWSAUTO
Default 0
SubType string
Default busybox
Default true
SubType string
Default false
Default OVERWRITE
Possible Values
OVERWRITEFAILWARNIGNORE
SubType string
SubType string
Default ["{{flow.namespace}}"]
Default true
Default { "image": "busybox" }
Default default
Default ALWAYS
Possible Values
IF_NOT_PRESENTALWAYSNEVER
Default true
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Default PT10M
Format duration
Default PT5S
Format duration
Default true
Default true
Default false
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT1H
Format duration
SubType integer
Default PT5S
Format duration
Default true
Default true
SubType string
Default ["https://www.googleapis.com/auth/cloud-platform"]
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Possible Values
ACTION_UNSPECIFIEDRETRY_TASKFAIL_TASKUNRECOGNIZED
Default v1
Default RSA
Default https://kubernetes.default.svc
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default true
SubType string
Default e2-medium
Default 2
Minimum >= 0
Maximum <= 10
Default true
SubType string
Default ["https://www.googleapis.com/auth/cloud-platform"]
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT5S
Format duration
Default PT1H
Format duration
Min length 1
SubType
SubType string
SubType string
Default IF_NOT_PRESENT
Possible Values
IF_NOT_PRESENTALWAYSNEVER
SubType string
Default true
SubType
SubType string
Default [ "" ]
SubType string
Default VOLUME
Possible Values
MOUNTVOLUME
Default PT0S
Format duration
SubType string
Default IF_NOT_PRESENT
Possible Values
IF_NOT_PRESENTALWAYSNEVER
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
SubType string
Default true
SubType array
SubType string
SubType string
Default PT5S
Format duration
Default true
Default { "request": { "memory": "2048", "cpu": "1" } }
Default true
Default PT15M
Format duration
Validation RegExp \d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
Default PT1H
Format duration