CLI class

CLI

Use CLI to execute Comware 7 CLI commands and create CLI objects.

Syntax

CLI(command=‘’, do_print=True)

Parameters

command: Specifies the commands to be executed. To enter multiple commands, use a space and a semicolon (;) as the delimiter. To enter a command in a view other than user view, you must first enter the commands used to enter the view. For example, you must enter system-view ;local-user test class manage’ to execute the local-user test class manage command.

do_print: Specifies whether to output the execution result:

Returns

CLI objects

Examples

# Add a local user with the username test.

<Sysname> python
Python 2.7.3 (default, May 24 2014, 14:37:26)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import comware
>>> comware.CLI('system-view ;local-user test class manage')

Sample output

<Sysname> system-view
System View: return to User View with Ctrl+Z.
[Sysname] local-user test class manage
New local user added.
<comware.CLI object at 0xb7f680a0>

get_output

Use get_output to get the output from executed commands.

Syntax

CLI.get_output()

Returns

Output from executed commands

Examples

# Add a local user and get the output from the command.

<Sysname> python
Python 2.7.3 (default, May 24 2014, 14:37:26)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import comware
>>> c = comware.CLI('system-view ;local-user test class manage', False)
>>> c.get_output()

Sample output

['<Sysname>system-view', 'System View: return to User View with Ctrl+Z.', '[Sysname]local-user test class manage']