I have a txt file created named "commands.txt" and it contains muliple commands ( multiple lines)
sh run vlan 504
sh run vlan 505
sh run vlan 700
sh run vlan 708
I want to run this against two switches and want to keep the output of the commands in a notepad.Just the raw output.My current code is
sh run vlan 504
sh run vlan 505
sh run vlan 700
sh run vlan 708
I want to run this against two switches and want to keep the output of the commands in a notepad.Just the raw output.My current code is
def shvlan(device,child): vlans = [] with open('commands.txt', 'r') as commands: for command in commands: child.sendline(command) child.expect('.*#') vlans.extend(child.after.splitlines()) child.close() print device + ' conn closed' print 'sh run vlan executed' return vlansAny Suggestion how to do that ?