Developing a Shell Script
You can develop, debug, and run shell scripts online. The developed scripts can be run in jobs. For details, see Developing a Job.
Prerequisites
- A shell script has been added. For details, see Creating a Script.
- A host connection has been created. The host is used to execute shell scripts. For details, see Managing Host Connections.
Procedure
- Log in to the DLF console.
- In the navigation tree of the Data Development console, choose .
- In the script directory list, double-click a script that you want to develop. The script development page is displayed.
- In the upper part of the editor, select script properties. Table 1 describes the script properties.
Table 1 Shell script properties Parameter
Description
Example
Host Connection
Selects the host where a shell script is to be executed.
-
Parameter
Parameter transferred to the script when the shell script is executed. Parameters are separated by spaces. For example: a b c. The parameter must be referenced by the shell script. Otherwise, the parameter is invalid.
For example, if you enter the following shell interactive script and the interactive parameters 1, 2, and 3 correspond to begin, end, and exit, you need to enter parameters 1, 2, and 3.
#!/bin/bash select ch in "begin" "end" "exit"; do case $ch in "begin") echo "start something" ;; "end") echo "stop something" ;; "exit") echo "exit" break; ;; *) echo "Ignorant" ;; esac
Interactive Input
Interactive information (passwords for example) provided during shell script execution. Interactive parameters are separated by carriage return characters. The shell script reads parameter values in sequence according to the interaction situation.
-
- Edit shell statements in the editor.
To facilitate script development, the DLF provides the script parameter function. The usage method is as follows:
Write the script parameter name and parameter value in the shell statement. When the shell script is referenced by a job, if the parameter name configured for the job is the same as the parameter name of the shell script, the parameter value of the shell script is replaced by the parameter value of the job.
An example is as follows:
a=1 echo ${a}
In the preceding command, a indicates the parameter name. It can contain only letters, digits, hyphens (-), underscores (_), greater-than signs (>), and less-than signs (<), and can contain a maximum of 16 characters. The parameter name must be unique.
- In the upper part of the editor, click Execute. After executing the shell statement, view the execution history and result of the script in the lower part of the editor.
- Above the editor, click to save the script.
If the script is created but not saved, set the parameters listed in Table 2.
Table 2 Script parameters Parameter
Mandatory
Description
Script Name
Yes
Name of the script. It contains a maximum of 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.
Description
No
Descriptive information about the script.
Select Directory
Yes
Directory to which the script belongs. The root directory is selected by default.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot