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.

Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.