Toolkits > SampleShellSink 1.0.0 > sample > TestShellSinkBadScript.spl
This sample application executes a Perl script containing a syntax error with the ShellSink operator, and logs the error messages from the Perl interpreter in the Streams application trace.
The script can be tested independently of Streams by entering these commands at a Linux prompt:
cd .../samples/SampleShellSink cat ./data/ozymandias.txt | ./etc/badscript.pl
composite TestShellSinkBadScript {
param
expression<rstring> $inputFile: dataDirectory() + "/ozymandias.txt";
expression<rstring> $shellCommand: "./etc/badscript.pl";
graph
// create a stream of text lines for the ShellSink operator below to consume
stream<rstring inputLine> InputStream = FileSource() {
param
file: $inputFile;
format: line; }
() as DebugInputStream = FileSink(InputStream) { param file: "debug.TestShellSinkBadScript.InputStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; }
// try to execute a Perl script containing a syntax error
stream<rstring stderrLine> STDERRStream = ShellSink(InputStream) {
param
command: $shellCommand; }
() as DebugSTDERRStream = FileSink(STDERRStream) { param file: "debug.TestShellSinkBadScript.STDERRStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; }
// log STDERR lines
() as LogSTDERRStream = Custom(STDERRStream as In) {
logic onTuple In: {
appTrc(Trace.info, "STDERR from command '" + $shellCommand + "': " + stderrLine); } }
}