Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First time user
#2
list_of_commands on each loop you currently have as
FIRST_PORT = 0
LAST_PORT = 3

for number in range(FIRST_PORT, (LAST_PORT +1)):
    list_of_commands = ["interface eth 0/0" + str(number), "shut"]
    print(list_of_commands)
which give the following commands
Output:
['interface eth 0/00', 'shut'] ['interface eth 0/01', 'shut'] ['interface eth 0/02', 'shut'] ['interface eth 0/03', 'shut']
In your description you stated E0/0-3, so maybe you want the following
FIRST_PORT = 0
LAST_PORT = 3

for number in range(FIRST_PORT, (LAST_PORT +1)):
    list_of_commands = [f"interface eth 0/{number}", "shut"]
    print(list_of_commands)
which will give
Output:
['interface eth 0/0', 'shut'] ['interface eth 0/1', 'shut'] ['interface eth 0/2', 'shut'] ['interface eth 0/3', 'shut']
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