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:
"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:
{
"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:
|
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:
{
"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:
|
PreCommand |
(Optional) Defines a command that executes before the job executes. |
PostCommand |
(Optional) Defines a command that executes after the job executes. |