Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Developing a Shell Script

Updated on 2022-08-17 GMT+08:00

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 Table 9.
  • You have locked the script. Otherwise, you must click Lock so that you can develop the script. A script you create or import is locked by you by default. For details, see the lock function.

Procedure

  1. Log in to the DataArts Studio console. Locate an instance and click Access. On the displayed page, locate a workspace and click DataArts Factory.
    Figure 1 DataArts Factory
  2. In the left navigation pane of DataArts Factory, choose Data Development > Develop Script.
  3. In the script directory list, double-click a script that you want to develop. The script development page is displayed.
  4. 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.

    N/A

    Parameter

    Parameter transferred to the Shell script when it is executed. Parameters are separated by spaces, for example, a b c.

    The parameter must be referenced by a location variable (for example, $1, $2, or $3) in the Shell script. Otherwise, the parameter is invalid. The location variable starts from 0. Variable 0 is reserved for storing the actual script name, variable 1 corresponds to the first parameter of the script, and so on. For example, $1, $2, and $3 reference parameters a, b, and c, respectively.

    Note: If a variable is referenced in the shell script, use the $args format instead of the ${args} format. Otherwise, the variable will be replaced by a parameter with the same name in the job.

    For example, if you enter a b c and run the following Shell script, b is displayed:

    echo $2

    Interactive Input

    Interactive information (for example, passwords) provided during shell script execution.

    For example, run the following interactive Shell script. Interaction parameters 1, 2, and 3 correspond to begin, end, and exit, respectively.

    • When the interaction parameter is set to 1, the execution result is start something.
    • When the interaction parameter is set to 2, the execution result is stop something.
    • When the interaction parameter is set to 3, the execution result is exit.
    #!/bin/bash
    select Actions in "begin" "end" "exit"
    do
    case $Actions in
    "begin")
    echo "start something" 
    break
    ;;
    "end")
    echo "stop something" 
    break
    ;;
    "exit")
    echo "exit" 
    break
    ;;
    *)
    echo "Ignorant" 
    ;;
    esac
    done
  5. Edit shell statements in the editor. To facilitate script development, DataArts Factory provides the following capabilities:
    • The script editor supports the following shortcut keys, which improve the script development efficiency:
      • Ctrl + /: Comment out or uncomment the line or code block at the cursor.
      • Ctrl + S: Save
      • Ctrl +Z: Cancel
      • Ctrl + Y: Redo
      • Ctrl + F: Search
      • Ctrl + Shift + R: Replace
      • Ctrl + X: Cut (cut a line when the cursor selects nothing).
      • Alt + mouse dragging: Select columns to edit a block.
      • Ctrl + mouse click: Select multiple lines to edit or indent them together.
      • Shift + Ctrl + K: Delete the current line.
      • Ctrl + (or ): Move the cursor rightwards (or leftwards) by word.
      • Ctrl + Home or Ctrl + End: Navigate to the beginning or end of the current file.
      • Home or End: Navigate to the beginning or end of the current line.
      • Ctrl + Shift + L: Double-click all the same character strings and add cursors to them to implement batch modification.
    • Script parameter function. Use this function in either of the following ways:
      1. 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.

      2. Configure parameters in the upper part of the editor. When you execute the shell script, the configured parameters are transferred to the script. Separate parameters by spaces, for example, a b c. The parameter must be referenced by the shell script. Otherwise, the parameter is invalid.

        Note: If a variable is referenced in the shell script, use the $args format instead of the ${args} format. Otherwise, the variable will be replaced by a parameter with the same name in the job.

    • Owner

      Click Basic Info to set the script owner and description.

  6. In the lower 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.
    NOTE:
    You can perform the following operations on execution results:
    • Double-click or right-click the name of an execution result tab to rename it. The name can contain a maximum of 16 characters.
    • Right-click the name of an execution result tab to close the current tab, all the tabs to the left or right of the current tab, all the other tabs, or all the tabs.
  7. 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.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback