Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Netmiko Loop question
#2
Here's my script so far. I apologize if sloppy and crude. New to netmiko, and trying to test network cables and make my life easier.


#!/usr/bin/env python
from netmiko import Netmiko
from netmiko import ConnectHandler
import time
import re

cisco = {
     'device_type': 'cisco_ios',
     'host': '10.1.1.1',
     'username': 'cisco',
     'password': 'cisco',
     'timeout': 35 * 60,
}


print()
print("running commands...")
net_connect = ConnectHandler(**cisco)


output = (net_connect.send_command('sh run | i hostname ').split()[1])
 
print()
print()   
print ('HOSTNAME:')
print()   
print(output)

output = (net_connect.send_command('sh run | i ip address 10 ').split()[2])  
print(output)

print()   
o1 = net_connect.send_command('show ip int brief | include Ethernet1/1.*up')
print(o1)
Output:
HOSTNAME: 4500lab 10.1.1.1 GigabitEthernet1/1 unassigned YES unset up up GigabitEthernet1/11 unassigned YES unset up up GigabitEthernet1/14 unassigned YES unset up up GigabitEthernet1/16 unassigned YES unset up up GigabitEthernet1/17 unassigned YES unset up up GigabitEthernet1/19 unassigned YES unset up up
Larz60+ write Oct-24-2020, 10:29 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Added for you this time
Reply


Messages In This Thread
Netmiko Loop question - by sc00ter - Oct-24-2020, 09:09 PM
RE: Netmiko Loop question - by sc00ter - Oct-24-2020, 09:21 PM
RE: Netmiko Loop question - by sc00ter - Oct-24-2020, 10:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have an issue with Netmiko Error reading SSH protocol banner omarhegazy 2 3,582 May-16-2022, 06:05 PM
Last Post: omarhegazy
  A question about 'Event loop is closed' fc5igm 2 2,232 Oct-05-2021, 02:00 AM
Last Post: fc5igm
Exclamation question about input, while loop, then print jamie_01 5 2,688 Sep-30-2021, 12:46 PM
Last Post: Underscore
  for loop question KEYS 1 1,738 Oct-27-2020, 11:42 PM
Last Post: jefsummers
  while loop question KEYS 2 2,025 Sep-26-2020, 11:02 PM
Last Post: KEYS
  New to programming, loop question tomyan 1 1,647 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  while loop question spalisetty06 2 1,861 Aug-13-2020, 04:18 PM
Last Post: buran
  question about for loop Than999 5 2,503 Jun-09-2020, 02:16 PM
Last Post: Emekadavid
  Sending Advanced Commands with Netmiko rogueakula 1 2,018 Oct-22-2019, 07:54 PM
Last Post: rogueakula
  Question about for loop not creating an infinite loop. FWendeburg 1 2,129 Feb-03-2019, 08:45 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020