= subprocess
:type: input
:status: beta
:categories: ["Utility"]



////
     THIS FILE IS AUTOGENERATED!

     To make changes, edit the corresponding source file under:

     https://github.com/redpanda-data/connect/tree/main/internal/impl/<provider>.

     And:

     https://github.com/redpanda-data/connect/tree/main/cmd/tools/docs_gen/templates/plugin.adoc.tmpl
////

// © 2024 Redpanda Data Inc.


component_type_dropdown::[]


Executes a command, runs it as a subprocess, and consumes messages from it over stdout.


[tabs]
======
Common::
+
--

```yml
# Common config fields, showing default values
input:
  label: ""
  subprocess:
    name: cat # No default (required)
    args: []
    codec: lines
    restart_on_exit: false
```

--
Advanced::
+
--

```yml
# All config fields, showing default values
input:
  label: ""
  subprocess:
    name: cat # No default (required)
    args: []
    codec: lines
    restart_on_exit: false
    max_buffer: 65536
```

--
======

Messages are consumed according to a specified codec. The command is executed once and if it terminates the input also closes down gracefully. Alternatively, the field `restart_on_close` can be set to `true` in order to have Benthos re-execute the command each time it stops.

The field `max_buffer` defines the maximum message size able to be read from the subprocess. This value should be set significantly above the real expected maximum message size.

The execution environment of the subprocess is the same as the Benthos instance, including environment variables and the current working directory.

== Fields

=== `name`

The command to execute as a subprocess.


*Type*: `string`


```yml
# Examples

name: cat

name: sed

name: awk
```

=== `args`

A list of arguments to provide the command.


*Type*: `array`

*Default*: `[]`

=== `codec`

The way in which messages should be consumed from the subprocess.


*Type*: `string`

*Default*: `"lines"`

Options:
`lines`
.

=== `restart_on_exit`

Whether the command should be re-executed each time the subprocess ends.


*Type*: `bool`

*Default*: `false`

=== `max_buffer`

The maximum expected size of an individual message.


*Type*: `int`

*Default*: `65536`


