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.
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.
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.
The network toolkit includes several sample applications that illustrate how to use this operator.
Required: command
Optional: stdinAttribute
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.
This function can be used in the output clause of either output port. It assigns a string value containing the shell command.
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.
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.
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.
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.
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.
Required: command
Optional: stdinAttribute
This required parameter takes an expression of type rstring that specifies the shell command or pipeline to be executed by the operator.
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.