Specifying a Script

Note:

The following information applies to step Creating an OS Command Job in Specifying a Script .

The value you specify in the OS Script field is used as stdin for the command interpreter, which defaults to /bin/sh on Linux and cmd/c on Windows. You can override this with another interpreter; for example: %perlbin%/perl. The shell scripts size is limited to 2 GB.

To control the maximum output size, set the mgmt_job_output_size_limit parameter in MGMT_PARAMETERS to the required limit. Values less than 10 KB and greater than 2 GB are ignored. The default output size is 10 MB.

The job status depends on the exit code returned by the last command in the script. If the last command execution returns 0, the job returns a status of Succeeded. If it returns any other value, it returns a job status of Failed. You should implement proper exception handling in the script and return non-zero exit codes when appropriate. This will avoid situations in which the script failed, but the job reports the status as Succeeded.

You can run a script in several ways:

  • OS Scripts — Specify the path name to the script in the OS Script field. For example:

    OS Script field: /path/to/mycommand Interpreter field:

  • List of OS Commands — You do not need to enter anything in the Interpreter field for the following example of standard shell commands for Linux or Unix systems. The OS's default shell of /bin/sh or cmd/c will be used.

         /usr/local/bin/myProg arg1 arg2
         mkdir /home/$USER/mydir
         cp /dir/to/cp/from/file.txt /home/$USER/mydir
         /usr/local/bin/myProg2 /home/$USER/mydir/file.txt
    

    When submitting shell-based jobs, be aware of the syntax you use and the targets you choose. This script does not succeed on NT hosts, for example.

  • Scripts Requiring an Interpreter — Although the OS shell is invoked by default, you can bypass the shell by specifying an alternate interpreter. For example, you can run a Perl script by specifying the Perl script in the OS Script field and the location of the Perl executable in the Interpreter field:

    OS Script field: <Enter-Perl-script-commands-here> Interpreter field: %perlbin%/perl

    The following example shows how to run a list of commands that rely on a certain shell syntax:

         setenv VAR1 value1
         setenv VAR2 value2
         /user/local/bin/myProg $VAR1 $VAR2
    

    You would need to specify csh as the interpreter. Depending on your system configuration, you may need to specify the following string in the Interpreter field:

         /bin/csh 
    

    You have the option of running a script for a list of Windows shell commands, as shown in the following example. The default shell of cmd/c is used for Windows systems.

         C:\programs\MyApp arg1 arg2
         md C:\MyDir
         copy C:\dir1x\copy\from\file.txt \home\$USER\mydir