In this lesson, we will cover:
- How to send a command and retrieve the output from a device.
- How to modify the expected response back from the device.
The scripts and code for this lesson can be found within the Netmiko repo under the directory: examples/002_device_interaction
.
Basic Usage
First of all, we can use send_command
to send a command to the device. Before we do so, we first enter enable mode via enable()
. For example.
ios_connection.send_command("show version")
By default, the Netmiko send_command()
works by sending the command, and then looking for the device prompt within the output. At the point, the command prompt is found Netmiko determines that this is the end of the output from the command. The command prompt that Netmiko looks for is obtained via the Netmiko method - find_prompt()
.
Below shows an example for collecting the output of show version
from the ios and eos based devices, using the previously created ConnectHandler
.