Command task runs a single shell command or
starts an external executable program during the workflow. We can write commands to delete reject files, copy a file,
or archive target files. You can use workflow parameters and variables in the
command.
When you run a
workflow, the workflow passes input data to a Command task in parameters and
variables. The Command task uses the input data to run the command. When the
Command task finishes running, the task passes output data back to the workflow
in variables.
The command syntax
depends on whether the Data Integration Service runs on UNIX or Windows.
Windows Use any DOS or batch file. For example, to copy a file from target
folder to source folder
Copy
C:\Informatica\PCExpress\tomcat\bin\target\xyz.txt
C:\Informatica\PCExpress\tomcat\bin\source\xyz.txt
To create a batch
file, write above command in a file and save the file as *.bat file. Then use
the file in command task.
UNIX Use any UNIX command or shell script. For
example, to copy a file from target folder to source folder
cp
C:\Informatica\PCExpress\tomcat\bin\target\xyz.txt
C:\Informatica\PCExpress\tomcat\bin\source\xyz.txt
To create a shell
script, write above command in a file and save the file as *.sh file. Then use
the file in command task.
Command Task Input
It is the data that
passes into a Command task from workflow parameters and variables. Assign a
Command task configuration property to task input to define the value of the
property in a workflow parameter or variable.
Command Task Output
It is the data that
passes from a Command task into workflow variables. Command task outputs
include general outputs and task specific outputs. The Data Integration Service
copies the Command task output values to workflow variables when the Command
task completes.
If the task fails,
the Data Integration Service copies the general task output values but not the
task specific output values to workflow variables.
General outputs Includes output data produced
by all tasks such as the task start time, end time, and whether the task
successfully ran.
Command task outputs Includes data produced by
the Command task when it runs the command.
Exit code returned by the command. A successful
command returns 0. An unsuccessful command returns a non-zero value.
Standard error message returned by the command.
By default, the first 1,024 characters of the error are returned. You can
change the length of the standard error in the Command task advanced
configuration properties.
Standard output returned by the command. By
default, the first 1,024 characters of the output are returned. You can change
the length of the standard output in the Command task advanced configuration
properties.
Command Task Advanced Properties
The Advanced tab for
a Command task includes properties that the task uses to run the command.
Working Directory
Directory from which
to run the command. You can also specify the working directory in the command
that you enter for the task. If you specify the directory in both locations,
the directory specified in the command overrides the directory specified in this
property.
Standard Output Length
Number of characters
to return in the standard output for the command. Maximum is 32,768 characters.
Default is 1024 characters.
Standard Error Length
Number of characters
to return in the standard error for the command. Maximum is 4096 characters.
Default is 1024 characters.