Operator ShellSink

Toolkits > com.ibm.streamsx.shell 2.1.0 > com.ibm.streamsx.shell > ShellSink

ShellSink is an operator for the IBM Streams product that executes a Linux command or command pipeline in a shell. Lines of text received as input tuples from the operator's required input port are written to the command's STDIN input. The command's STDOUT and STDERR output are discarded.

The command or pipeline is specified as an operator parameter. Command pipelines can be specified with the usual shell pipe character "|".

The command is executed in separate Linux shell, as specified by the /bin/sh program, which is the Bash shell on most Linux systems.

The ShellSink operator is part of the 'com.ibm.streamsx.shell' toolkit.

Processes and Threads

The ShellSink operator creates a separate process to execute the shell command or pipeline, and creates a separate thread within the operator's process to receive output from the command.

Exceptions

The ShellSink operator throws an exception if it is unable to execute the /bin/sh program, which is the Bash shell on most Linux systems.

Sample Applications

The network toolkit includes several sample applications that illustrate how to use this operator.

Summary

Ports
This operator has 1 input port and 1 output port.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 2 parameters.

Required: command

Optional: stdinAttribute

Metrics
This operator does not report any metrics.

Properties

Implementation
C++
Threading
Never - Operator never provides a single threaded execution context.

Input Ports

Ports (0)

The ShellSink operator has one required input port.

Lines of text are taken from input tuples and written to the shell command's STDIN input. The stdinAttribute parameter specifies the input attribute containing input lines, or if not specified, the first input attribute of type rstring is used.

Properties

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Output Functions
STDERR_functions
rstring commandLine()

This function can be used in the output clause of either output port. It assigns a string value containing the shell command.

rstring stdinLine()

This function can be used in the output clause of either output port. It assigns a string value containing the most recently received line sent to the shell command's STDIN input.

Note that shell commands execute asynchronously from the operator, and may emit no output, or many lines of output, for each input line, so the value of this function is not synchronized with the output tuples produced by either output port.

rstring stderrLine()

This function can only be used in the output clause of output port 1. It assigns a string value containing one line of text written to STDERR by the shell command.

list<uint64> lineCounters()

This function can be used in the output clause of either output port. It assigns a list of three uint64 numbers: counts of the shell command's STDIN, STDOUT, and STDERR lines, respectively.

<any T> T copy()

Output attributes that match input attributes in name and type are automatically copied from those input attributes in the most recently received input tuple.

Note that shell commands execute asynchronously from the operator, and may emit no output, or many lines of output, for each input line, so the attributes copied are not synchronized with the output tuples produced by either output port.

Ports (0)

The ShellSink operator has one optional output port.

If output port 0 is configured, it produces a tuple for each line of text written to STDERR by the shell command. The stderrAttribute parameter specifies the output attribute STDERR lines are assigned to, or if not specified, the first output attribute of type rstring is used. Alternatively, the function 'stderrLine()' can be used in an output clause for port 0 to assign STDERR lines to an output attribute.

Properties

Parameters

Required: command

Optional: stdinAttribute

command

This required parameter takes an expression of type rstring that specifies the shell command or pipeline to be executed by the operator.

Properties

stdinAttribute

This optional parameter specifies an input attribute of type rstring that contains lines of text to be written to the shell command's STDIN input.

If this parameter is not specified, STDIN input lines are taken from the first input attribute of type rstring.

Properties

Libraries

No description for library.
Include Path: ../../impl/include