Toolkits > SampleShellPipe 1.1.0 > sample > TestShellPipeBadScript2.spl
This sample application executes a Perl script containing a syntax error with the ShellPipe 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/SampleShellPipe cat ./data/ozymandias.txt | ./etc/badscript.pl
composite TestShellPipeBadScript2 { param expression<rstring> $inputFile: dataDirectory() + "/ozymandias.txt"; expression<rstring> $scriptPath: dataDirectory() + "/../etc/"; //consider to use getApplicationDir() / but so it works also in product version 3.x expression<rstring> $shellCommand: getSubmissionTimeValue("shellCommand", "badscript.pl"); expression<float64> $rate: (float64)getSubmissionTimeValue("rate", "1000000.0"); graph // create a stream of text lines for the ShellPipe operators below to consume stream<rstring inputLine> InputStream = FileSource() { param file: $inputFile; format: line; } stream<rstring inputLine> InputStreamDelayed = Throttle(InputStream) { param rate : $rate; includePunctuations: true; } () as DebugInputStream = FileSink(InputStreamDelayed) { param file: "debug.TestShellPipeBadScript.InputStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } // try to execute a Perl script containing a syntax error ( stream<rstring stdoutLine> STDOUTStream ; stream<rstring stderrLine> STDERRStream ) = ShellPipe(InputStreamDelayed) { param abortOnError: true; command: $scriptPath + $shellCommand; } () as DebugSTDOUTStream = FileSink(STDOUTStream) { param file: "debug.TestShellPipeBadScript.STDOUTStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } () as DebugSTDERRStream = FileSink(STDERRStream) { param file: "debug.TestShellPipeBadScript.STDERRStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } // log STDERR lines to Streams application trace () as LogSTDERRStream = Custom(STDERRStream as In) { logic onTuple In: { appTrc(Trace.info, "STDERR from command '" + $shellCommand + "': " + stderrLine); } } config restartable : true; }