Enhancing Your First Job

This topic is interesting for first users of Automic Automation who have already read Creating Your First Job. This topic explains how to enhance the Job. The basic Job retrieves the data about the free space available on drive C on the Windows server. In this example, the Job prepares the results of the query and the report so that they can be further processed. For this purpose, it contains an object variable and a script. The object variable is replaced by the results of the query (free disk space). The script uses the variable and prepares the report.

The example described here addresses not only developers and object designers. It is also relevant for operators and managers. As an operator or manager, to be able to monitor processes, analyze them and identify potential problems, you must understand how objects work and how they interact.

What You will Learn

Overview

  1. Enhance the Job with an Object Variable
  2. Execute the Job and Check the Report
  3. Write the Script to Prepare the Results
  4. Execute the Job and Check the Report Again
  5. Open the List of Executions

Enhance the Job with an Object Variable

The variable will store the values retrieved by the Windows command. We need the variable to be able to use the retrieved values in the script that will prepare the results for further processing.

  1. Open the JOBS.WIN.RETRIEVE.FREE.DISKSPACE Job that you have previously created.
  2. In the left navigation pane, expand the Variables & Prompts drop down list and select Variables.
  3. Click on the Name cell in the first row to activate it and enter the name of the object variable. In our example, it is called &FREESPACE#.
  4. Save the Job.

This is what it looks like:

Screenshot that shows the Job opened to the Variables page. It contains the variable &FREESPACE#.

Note: Your system has various types of variables. For more information about the types of variables that are available, see Variables and VARA Objects.

Execute the Job and Check the Report

Execute the Job and then open the report to see what is different now compared to the basic Job we have created previously.

  1. Click the Execute button in the toolbar.
  2. The Execute Object confirmation dialog is displayed. Click Execute.
  3. The Job is executed. A pop up is displayed at the top of the screen during a few seconds. It confirms that you have executed the object and it contains a link to the execution report.
  4. Open the report and expand the drop down list:

    Screenshot showing the Reports window, where the drop down list is ecpanding showing the types of reports that are available for selection: Logging (LOG), Report ((REP), Activation (ACT), and Directory

An additional type of report is available now, namely, the Activation (ACT)report. There are two main reasons for this.

Write the Script to Prepare the Results

Now we will write a script that prepares the values (free disk space) provided by the Windows command. This step is necessary to be able to use these values later in other objects.

Job objects have three pages where you can enter scripts:

Screenshot showing the left pane in the Job object page. The node for the Process page is expanded and the sub pages are displayed. They are the Pre Process and the Post Process pages.

The scripts on the different pages are processed at different stages of the Job execution. The script on the Pre Process page prepares the Job for execution. The Process page contains the JCL. The script on the Post Process page is processed when the Job has finished.

Since we need the results of the Job to pass them on to other objects, we must write the script on the Post Process page. We will use the Automation Engine scripting language for this purpose.

  1. Expand the Process drop down list.
  2. Select Post Process. Here is where you write the scripts that affect the report.
  3. Enter the following script:

    :SET &HND# = PREP_PROCESS_REPORT("JOBS",, "REP","Total # of free bytes*","COL=DELIMITER","DELIMITER=*:*" )

    :PROCESS &HND#

    :  SET &FREESPACE# = GET_PROCESS_LINE(&HND#,2)

    :  SET &FREESPACE# = STR_TRIM(&FREESPACE#);

    :  PRINT &FREESPACE#

    :ENDPROCESS

  4. Save the Job.

This is what it looks like:

Screenshot shiowing the Post Process page of the Job, where the script is displayed.

For more information about the execution stages of objects, see Execution Stages. For more information about what happens with the scripts on each process page, see Process Pages.

Script Description

This is what the script does:

For more information about the Automation Engine scripting language and the script elements used in this example, see:

Execute the Job and Check the Report Again

Execute the Job and then open the report again. In the reports drop down list, the Post Process (POST)report is also available now. This report logs the steps that have been carried out by the script on the Post Process page.

Screenshot showing the Reports window, where the drop down list is ecpanding showing the types of reports that are available for selection: Logging (LOG), Report ((REP), Activation (ACT), Post Process (POST), and Directory

Open the List of Executions

So far, we have executed the Job several times. Your system records every execution and stores them in various forms, one of them being the lists of Executions. These lists provide detailed information about what happened during each execution of each task. The Executions lists help you monitor and troubleshoot your processes.

  1. Return to the Job definition pages and click the Executions button in the toolbar.
  2. The Executions of JOBS.WIN.RETRIEVE.FREE.DISKSPACE view is displayed.

    This is what it looks like:

    Screenshot showing the list of Executions of the Job.

    Each record in the list represents an execution run. By default, the most recent execution is displayed at the top of the list. Recording the execution data is triggered as soon as an object is activated and ends when the execution is completed.

Tip: Right-click an entry in the list and explore the context-menu options that are available for each execution run.

Next

The next steps in this Getting Started guide are to create a Notification object that retrieves the result of the Job and sends an e-mail. After that, we will create a Workflow to connect the Job and the Notification objects.

For more information, see: