Statements

Built-in Commands

You can use the following built-in commands inside any lifecycle block (with the exception of onerror and throw). These commands are operating-system independent.

Built-in Commands

Command

Description

mkdir "dir-name"

Creates a directory.

copy "src-file" "dest-file"

Copies a file. Typically, the prejob block is used to copy input files from the Driver machine to the staging directory on the Manager, which can be referenced as $DSSTAGEDIR. In the task or pretask block, the input file is copied from the staging directory to the Engine’s local filesystem. Output files are copied in the reverse direction.

rmdir "dir-name"

Removes a directory. The directory must be empty.

delete "file"

Deletes a file. Supports the * wildcard.

log "log-message"

Writes a message to the Driver log (in prejob or postjob lifecycle blocks) or the Engine log (in pretask, task, or posttask lifecycle blocks).

execute [stdin="stdin=file"]
[stdout="stdout-file"]
[stderr="stderr-file"]
"command-to-execute"

Executes a command on the local machine using the shell specified with the shell command. A subshell is spawned for the command unless specified otherwise with the shell command. The subshell has the path available on the Engine (as set in the Library Path property of the Engine Configuration) or Driver.

Before running custom executables, deploy those executables to Engines using GridServer’s application resource deployment feature. See Resource Deployment for more details.

shell "shell-type"

Specifies the shell to spawn for commands run by the execute command. The defaults are /bin/bash for Linux and cmd.exe for Windows. If you set this to none, no shell is spawned.

env (variable)

Returns the value of the specified environment variable. If the variable is a string literal, enclose it in quotes. Returns an empty string for nonexistent variables.

onerror <ignore|retry|fail>

Indicates what happens when an execute command returns with a nonzero exit code. ignore takes no action; retry reschedules the task on another Engine; and fail returns an exception back to the Driver. The default is fail. When used with retry, you can use onerror only within the job or task blocks.

throw "message"

Causes the task to fail and throws an exception. The message is displayed on the Driver and written into the Driver log. This cannot be used in the posttask lifecycle block.

Enclose arguments to all statements in quotes, except for arguments to onerror. If you include a linebreak in a quoted argument, escape it with a backslash.

The mkdir, copy, delete, and rmdir commands are not dependent on the operating system. Pathnames automatically translate to work on the appropriate platform. For example, mkdir "sample/log1" creates sample\log1 on Windows systems.