Toolkits > SampleShellSource 1.1.0 > sample > TestShellSourceInputCommands.spl
This sample application ingests valid and invalid shell commands from a text file, executes the commands with ShellSource operators that illustrate how to specify the operator's optional parameters, and writes STDOUT, STDERR, and exit status from each command into files.
composite TestShellSourceInputCommands { param expression<rstring> $commandFile: dataDirectory() + "/commands.txt"; type StatusType = rstring command, int32 exitCode, rstring exitReason, list<uint64> counters ; graph // create a stream of shell commands for the ShellSource operators below to consume stream<rstring command> CommandStream = FileSource() { param file: $commandFile; format: line; } () as DebugCommandStream = FileSink(CommandStream) { param file: "debug.TestShellSourceInputCommands.CommandStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } // execute a stream of shell commands and produce tuples from the lines they write to STDOUT stream<rstring stdoutLine> A_STDOUTStream = ShellSource(CommandStream) { param commandAttribute: command; stdoutAttribute: "stdoutLine"; } () as DebugA_STDOUTStream = FileSink(A_STDOUTStream) { param file: "debug.TestShellSourceInputCommands.A_STDOUTStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } // execute a stream of shell commands and produce tuples from the lines they write to STDOUT and STDERR, plus a status tuple with the commands' exit codes ( stream<rstring line> B_STDOUTStream ; stream<rstring line> B_STDERRStream ; stream<StatusType> B_StatusStream ) = ShellSource(CommandStream) { output B_StatusStream: command = commandLine(), exitCode = exitCode(), exitReason = exitReason(), counters = lineCounters(); } () as DebugB_STDOUTStream = FileSink(B_STDOUTStream) { param file: "debug.TestShellSourceInputCommands.B_STDOUTStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } () as DebugB_STDERRStream = FileSink(B_STDERRStream) { param file: "debug.TestShellSourceInputCommands.B_STDERRStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } () as DebugB_StatusStream = FileSink(B_StatusStream) { param file: "debug.TestShellSourceInputCommands.B_StatusStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } // execute a stream of shell commands and produce tuples from the lines they write to STDOUT and STDERR, plus a status tuple with the commands' exit codes ( stream<rstring stdoutLine> C_STDOUTStream ; stream<rstring stderrLine> C_STDERRStream ; stream<StatusType> C_StatusStream ) = ShellSource(CommandStream) { param commandAttribute: command; stdoutAttribute: "stdoutLine"; stderrAttribute: "stderrLine"; output C_StatusStream: command = commandLine(), exitCode = exitCode(), exitReason = exitReason(), counters = lineCounters(); } () as DebugC_STDOUTStream = FileSink(C_STDOUTStream) { param file: "debug.TestShellSourceInputCommands.C_STDOUTStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } () as DebugC_STDERRStream = FileSink(C_STDERRStream) { param file: "debug.TestShellSourceInputCommands.C_STDERRStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } () as DebugC_StatusStream = FileSink(C_StatusStream) { param file: "debug.TestShellSourceInputCommands.C_StatusStream.out"; format: txt; hasDelayField: true; flush: 1u; writePunctuations: true; } }