Hello everyone I want to make a Python script with a menu and several possibilities but I have a problem. When I run my script everything works
I can type the information to connect but I have the right to the following errors:
Traceback (most recent call last):
File "test.py", line 38, in <module>show_int()File "test.py", line 24, in show_intoutput = net_connect.send_command("show ip int brief")AttributeError: 'NoneType' object has no attribute 'send_command'
Here is my script I have tried a lot of changes but I don't see where the problem is.
Thanks for your help
from csv import reader from datetime import date, datetime from netmiko import ConnectHandler import getpass import os def get_connection(): device = { 'device_type': 'cisco_ios', 'host': input("Host: "), 'username': input("Utilisateur: "), 'password': getpass.getpass("Mot de passe: "), 'secret': getpass.getpass("Mot de passe Secret: "), } net_connect = ConnectHandler(**device) net_connect.enable() def show_int(): net_connect = get_connection() output = net_connect.send_command("show ip int brief") print (output) def show_route(): net_connect = get_connection() route = net_connect.send_command("show ip route") print (route) print("1: Show int") print("2: Show route") choice = input("Make a choice: ") if choice == "1": show_int() elif choice == "2": show_route()
No comments:
Post a Comment