OS Command and Script Jobs

The following OS jobs enable you to execute commands and scripts on your specific, distributed operating system:

Job:Command

The following example shows how to define an OS command job:

Copy
"JobName"
{
   "Type" : "Job:Command",
   "Command" : "echo Hello",
   "PreCommand": "echo before running main command",
   "PostCommand": "echo after running main command",
   "Host" : "myhost.mycomp.com",
   "RunAs" : "user1"
}

The following table describes the OS command job parameters.

Parameter

Description

Host

Defines the name of the Agent or host group where this job runs.

RunAs

Determines the operating system user that runs the job.

PreCommand

(Optional) Defines a command that executes before the job executes.

PostCommand

(Optional) Defines a command that executes after the job executes.

Job:Script

The following example shows how to define an OS script job:

Copy
{
   "JobWithPreAndPost"
   {
      "Type" : "Job:Script",
      "FileName" : "task1123.sh",
      "FilePath" : "/home/user1/scripts",
      "PreCommand": "echo before running script",
      "PostCommand": "echo after running script",
      "Host" : "myhost.mycomp.com",
      "RunAs" : "user1",
      "Arguments":[
         "arg1",
         "arg2"]
   }
}

The following table describes the OS script job parameters.

Parameter

Description

FileName

Defines the script filename.

FilePath

Defines the script directory path, in the following format:

  • Windows: C:\\<Directory>\\<Subdirectory>

    You must double \ on Windows.

  • UNIX/Linux: ~/<directory>/<subdirectory>/

PreCommand

(Optional) Defines a command to execute before the job is executed.

PostCommand

(Optional) Defines a command to execute after the job is executed.

Host

Defines the name of the Agent or host group where this job runs.

RunAs

Determines the operating system user that runs the job.

Arguments

(Optional) Defines an array of strings that are passed to the script.

Job:EmbeddedScript

The following example shows how to define an OS embedded script job:

Copy
{
   "EmbeddedScriptJob":
   {
      "Type":"Job:EmbeddedScript",
      "Script":"#!/bin/bash\\necho \"Hello, World!\"",
      "Host":"myhost.mycomp.com",
      "RunAs":"user1",
      "FileName":"myscript.sh",
      "PreCommand": "echo before running script",
      "PostCommand": "echo after running script"
   }
}

The following table describes the Embedded Script job parameters.

Parameter

Description

Script

Defines full content of the script.

Rule:

Size: 1–64 Kilobytes

Host

Defines the name of the Agent or host group where this job runs.

RunAs

Determines the operating system user that runs the job.

FileName

Defines the script filename, which is used for the following purposes:

  • The file extension instructs Control-M how to read the script. If this is the only purpose of this property, the file does not have to exist.

  • If you specify an alternative script override with the OverridePath parameter, the FileName parameter indicates the name of the alternative script file.

PreCommand

(Optional) Defines a command that executes before the job executes.

PostCommand

(Optional) Defines a command that executes after the job executes.