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

RESTful API Reference

CloudEngine 12800 and 12800E V200R005C10

This document describes the OPS APIs supported by the device, including OPS-supported operations, request examples, elements in the requests, response examples, elements in the responses, and response status codes.
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).
Read User Inputs on User Terminals

Read User Inputs on User Terminals

  • Function Description

    The OPS provides an interface for reading user inputs on the CLI terminal when the Python script is being executed on the front end or the CLI terminal waits for script execution.

  • Command Prototype

    opsOb.terminal.read(maxLen=512, timeout=30, vty=None)

  • Parameter Description
    Table 31-6 Parameters supported by APIs for reading user inputs on user terminals

    Method

    Description

    opsObj

    Specifies an OPS object. It is obtained using ops.ops() in instance mode.

    maxLen

    Specifies the maximum number of characters allowed to be input. The default value is 512 characters.

    timeout

    Specifies a timeout period for waiting for user inputs. The default value is 30s.

    vty

    Specifies a user terminal. Currently, user inputs can be read only on user terminals that wait for script execution or execute the script on the front end.

    You can enter environment('_cli_vty') to obtain the VTY name or enter None.

  • Description of Return Values

    None: indicates a user input timeout, a user has entered CTRL+C, or the parameter is incorrect.

    Null character string: indicates that a user has pressed Enter.

  • Example
    test.py
    
    import ops
    
    def ops_condition(_ops):
        ret, reason = _ops.cli.subscribe("corn1","device",True,True,False,20)
        return ret
    
    def ops_execute(_ops):
        _ops.terminal.write("Enter your passwd:",None)
        passwrd,ret = _ops.terminal.read(10,15,None)
        print(passwrd)

    When the front end executes the script, the character string entered by a user on the CLI terminal is output.

Translation
Download
Updated: 2019-04-03

Document ID: EDOC1100075372

Views: 10774

Downloads: 16

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