Command Execution
To execute a command on a local machine within a PDS script, you can use the execute statement. A subshell is spawned for the command, unless specified otherwise with the shell command. The subshell has the path available on the Engine or Driver. The execute statement also enables you to set the stdin, stdout, and stderr used by the command. For example, the following script is a simple PDS script that uses execute:
job simplecommand
task 1
execute stdin="input.txt" stdout="output.txt"
stderr="error.txt"
"sort"
end
end job
This script creates one task, which takes the contents of input.txt, sends them to the sort command on an Engine, collects the results into the file output.txt, and collects any errors in error.txt. All three files are located on the Engine in the Engine’s installation directory.
You can also use the “backtick” syntax (such as ‘command‘) to do the same thing as execute, but the input, output, error, and shell cannot be set.
The shell statement can be used to specify the shell to be used for commands run by the execute command. The default is /bin/bash for UNIX and cmd.exe for Windows. This can be set to none, whereupon no shell is spawned.
You can also change the behavior of a script based on the return code of a command run with the execute statement by using the onerror statement. For more information about the onerror statement, see the TIBCO GridServer® Developer's Guide.