Creating Script from Scratch


This topic introduces how to create and develop script from scratch.

Before You Start

Prepare data sources and data that are used by the script.

Creating Script

Take the following steps to create and develop script from scratch.

  1. Log in EnOS Management Console and select Batch Data Processing > Scripts from the left navigation menu. Then, click + above the script list or click Create Script in the blank page to create script.

  2. In the New Script window, complete the following settings, and click Create.

    • Type: Select the script type (supporting Hive SQL and Shell scripts)

    • Directory: Select the directory to store the script file

    • Method: Select Create from Scratch

    • Name: Enter the script file name

      ../_images/adding_script_from_scratch.png
  3. View the created script file, which contains information about the owner and time when the script is created.

    • Created Hive SQL script file is as follows:

      ../_images/added_script.png


    • Created Shell script file is as follows:

      ../_images/added_script_shell.png
  4. Edit the script in the editor. When you enter script code, the editor will display prompt information in real time. Click Save to save editing changes.

    • Editing Hive SQL script:

      ../_images/saving_script.png


    • Editing Shell script:

      ../_images/saving_script_shell.png

Running Script

When you complete editing the script, you can then run the script, view the running result, and debug the script. The following section uses a Hive SQL script as example to show how to run and debug script.

  1. Click Basic Configuration from the right edge of the script editor and complete the basic configuration for running the script:

    • Owner: Enter owners of the script (who have the permission to edit and use the script).
    • Execution Queue: Select the Batch Processing - Queue resource that is requested through Resource Management.
    • Running Resource: Select the Batch Processing - Container (Design Mode) resource for running the script.
    ../_images/script_configuration.png
  2. (Optional) Click Parameter Config from the right edge of the script editor and complete the configuration of parameters for running the script.

    ../_images/script_params.png
  3. Click Run. The script will be run with the specified configuration. The running result will be displayed in the Result section (The running result can display at most 3,000 records).

    ../_images/script_result_1.png
  4. If you want to run specific lines only, select the code lines, and click Run.

    ../_images/script_result_2.png
  5. If errors occur, you can debug with the running logs.

Managing Scripts

After creating and editing scripts, you can manage the scripts in the script list by the following operations:

  • Using the operation items above the script list, you can search scripts, create script directories, refresh the script list, and filter the script view.
  • Create a script quickly by cloning an existing script.
  • Move scripts among directories or delete scripts.

Note

Only the script owners and the OU owner have the permission to edit the script configuration.