Configuration.exec()
Description
Appends an exec filter to the current pipeline layout.
An exec filter starts a child process and links to its standard input and output.
- INPUT - The child process's standard input Data stream.
- OUTPUT - The child process's standard output Data stream.
The external process is started from a shell command given by the command parameter when the first event hits the filter's input. The command can be a string or a function that returns a dynamic string.
Only Data events on the filter's input are fed into the process's standard input as a byte stream. All other events are discarded. On the output of the filter, the process's standard output can be received as Data events. When the process exits, a StreamEnd event will be received.
When the filter is destroyed with its pipeline, the process (if any) will be killed accordingly.
Syntax
pipy().pipeline().exec(command)pipy().pipeline().exec(() => whatCommand())
Parameters
exec(command)
A string or a function that returns a string containing the shell command to execute.
The same Configuration object.
Example
pipy().task().onStart(() => new Message).exec('ls -l') // Execute shell command: `ls -l`.print() // Print out the standard output from that command