No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

Configuration Guide - Device Management

S2720, S5700, and S6720 V200R013C00

This document describes the configurations of Device Management, including device status query, hardware management, Stack, SVF, cloud-based management, PoE, monitoring interface, OPS, energy-saving management, information center, fault management, NTP, synchronous ethernet, PTP.
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Reading User Input from a Terminal

Reading User Input from a Terminal

Interface Name

Reading user input from a terminal

Application Phase

Execution phase and CLI event synchronization waiting mode

API Prototype

result1_value, result2_description = ops.terminal.read(maxLen=512, timeout=30, vty=None)

Description

Parameter

Description

Value

maxLen

Indicates the maximum length of the entered character string.

The value is an integer that ranges from 1 to 512. The default value is 512.

timeout

Indicates the timeout interval.

The value is an integer that ranges from 0 to 60, in seconds. The default value is 30 seconds.

vty

Indicates a user terminal.

The value is None or the VTY channel name obtained using ops.environment.get("_cli_vty").

Return Value

The result1_value and result2_description in the API prototype indicate return values.

The first return value is as follows:
  • None: indicates that waiting process times out or a user presses Ctrl+C.

  • Empty string: indicates that a user presses Enter directly.

  • 1: indicates that an error is returned. The reason of the error is described by the second return value.

  • Other string: indicates user input (only when the second return value is success).

The second return value is as follows:

  • success: indicates that user input from a terminal is read successfully.

  • Other string: indicates the reason why user input from a terminal failed to be read.

Usage Description

The command line event must be subscribed, and you must wait until the script execution is complete after the command is executed. That is, the subscribed event must be defined through ops.cli.subscribe, and sync must be set to True.

This API enables you to obtain the information entered by users from a terminal and use it in scripts. A maximum of 10 ops.terminal.read APIs are supported in one script.

Example

When a subscription event is matched, you can read user input from the terminal.

value, descri_str = ops.terminal.read(maxLen=512, timeout=30, vty=None)
Translation
Download
Updated: 2019-04-20

Document ID: EDOC1100065674

Views: 37371

Downloads: 328

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next