A single command or a delimited batch of commands may be run. The delimiter is a space and a semicolon, " ;". Configuration commands must be in fully qualified form. output = cli("show version") output = cli("show version ; show ip interface brief") output = cli("configure terminal ; interface gigabitEthernet 0/0 ; no shutdown") Args: command (str): The exec or config CLI command(s) to be run. Returns: string: CLI output for show commands and an empty string for configuration commands. Raises: errors.cli_syntax_error: if the command is not valid. errors.cli_exec_error: if the execution of command is not successful. >>> help(clip) Help on function clip in module cli:
clip(command) Execute Cisco IOS CLI command(s) and print the result. A single command or a delimited batch of commands may be run. The delimiter is a space and a semicolon, " ;". Configuration commands must be in fully qualified form. clip("show version") clip("show version ; show ip interface brief") clip("configure terminal ; interface gigabitEthernet 0/0 ; no shutdown") Args: command (str): The exec or config CLI command(s) to be run. Cisco Python Module to Execute IOS CLI Commands Guest Shell must be enabled for Python to run. For more information, see the Guest Shell chapter. Note The Python programming language uses six functions that can execute CLI commands.
These functions are available from the Python CLI module. To use these functions, execute the import cli command. Arguments for these functions are strings of CLI commands. To execute a CLI command through the Python interpreter, enter the CLI command as an argument string of one of the following six functions: cli.cli(command) —This function takes an IOS command as an argument, runs the command through the IOS parser, and returns the resulting text. If this command is malformed, a Python exception is raised. The following is sample output from the cli.cli(command) function:
>>> import cli >>> cli.clip('configure terminal; interface loopback 10; ip address 10.10.10.10 255.255.255.255') *Mar 13 18:39:48.518: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback10, changed Shells and Scripting Cisco Python Module to Execute IOS CLI Commands Programmability Configuration Guide, Cisco IOS XE 17.16.x 135