Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First time user
#1
Help Please. This is my first time attempting Python. My testing lab has 4 Ethernet interfaces E0/0-3 on my Router. I am writing a script to shutdown all interfaces at 1900 hrs.
My script only shuts down E0/0 no others. Please would some tell me what I am doing wrong, and possibly giving me some pointers on how to input the time variables? I have uploaded my script for review.

netshud.py
from netmiko import ConnectHandler
import subprocess

Network_Device ={"host": "192.168.2.119",
                 "username": "admin",
                 "password": "cisco",
                 "device_type": "cisco_ios",
                 "secret": "cisco",

     }

Connent_to_Device = ConnectHandler(**Network_Device)
Connent_to_Device.enable()

First_Port = 0
Last_Port = 3

To_Execute = Connent_to_Device.send_command("sh ip interface brief")
print(To_Execute)

for Port in range(First_Port, (Last_Port +1)):
    List_of_Commands = ["interface eth 0/0" + str(Port), "shut"]
    To_Execute = Connent_to_Device.send_config_set(List_of_Commands)
print(To_Execute)

To_Execute = Connent_to_Device.send_command("sh ip interface brief")
print(To_Execute)
Thank
Cris
Larz60+ write Jun-07-2021, 02:52 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.

Fixed for you this time. Please use bbcode tags on future posts.
Reply


Messages In This Thread
First time user - by cris - Jun-07-2021, 04:25 AM
RE: First time user - by Yoriz - Jun-07-2021, 04:14 PM

Forum Jump:

User Panel Messages

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