我的代码状态行对我的conn.run行具有无效的自动命令
我的代码:
`from fabric import Connection
ip = input("enter ip address: ")
# Connect to the switch using Fabric
conn = Connection(ip, user='netstudent', connect_kwargs={"password": "0wlMan5151"})
# Execute a command to add a description to a specific interface
conn.run('configure terminal')
conn.run('interface gi 1/0/3')
conn.run('#description [Configured by Fabric]')
conn.run('end')
result = conn.run('show interfaces description', hide=True)
print(result.stdout)
# Execute a command to change VLANs
conn.run('configure terminal')
conn.run('interface gigabitethernet 1/0/3')
conn.run('switchport access vlan 430')
conn.run('end')
result = conn.run('show interfaces switchport', hide=True)
print(result.stdout)
# Execute a command to show environment
result = conn.run('show environment', hide=True)
print(result.stdout)
`
我尝试过创建函数并压缩代码,但它没有运行。上面的当前代码是我最接近成功登录交换机并“创建配置”的代码