Skip to main content

Run Command job

In briefA Run Command job runs one command line on a Universal Agent machine and captures its output. By default it runs through the system shell, so pipes and redirects work. By default it succeeds on exit code 0 and fails on anything else. Exit criteria and output parsing let you change that rule when the command uses its own codes.

WhereIn Design › Workflows, open a workflow and open the job in the Job Editor (open its context menu on the canvas › Edit Job). On the Job Definition tab, choose Run Command as the job type, set the fields under Job Parameters, and pick a Universal Agent under Agent Assignment. The job output and its Termination text show what decided the outcome.

WhenUse a Run Command job when:

  • the work is one command line, or one program with arguments;
  • a command's own exit codes do not follow the usual "0 is success" rule;
  • a command exits 0 but prints an error you need to catch.

When the logic is more than one line, use Run Script. On a legacy LSAM machine, use that machine's command job type — see LSAM commands.

How

  1. Choose Run Command as the job type and enter the Command.
  2. Add Arguments, a Working Directory or Environment Variables if the command needs them.
  3. Turn Run via Shell off only to start a program directly, with no shell features.
  4. Add Exit Criteria or Output Parsing rules if the default rule does not fit.
  5. Assign the job to a Universal Agent and save.

For the full steps, see Run a command.

Notes
  • Output parsing runs first and can change the exit code. Exit criteria then judge that code.
  • An exit criterion that matches means the job failed. With criteria set, Fail on Error is ignored.
  • Output parsing is case sensitive and supports only * and ?, not regular expressions. The first matching rule wins.
  • The command does not get the agent's secret variables. Pass what it needs as job Environment Variables.
Watch out
  • Every Run Command job stops after one hour, and no setting changes that. A command the agent stops always fails, whatever the criteria say.
  • Kill does not stop the command on a Universal Agent.
  • Only the first and last 512 KB of each output stream are searched. A match in the middle of a large output is missed.
  • With Fail on Error off and no exit criteria, the exit code can never fail the job.