首页 > 解决方案 > Python 初学者 - SSH 和用户输入问题

问题描述

我得到了一个脚本,它允许我登录到设备,然后将输出转储到文本文件中。这太棒了。我需要能够为多个设备执行此操作。所以我想做的是这个。我运行脚本,它要求我输入 IP。我输入 IP,它登录然后将输出转储到文件中,但我似乎无法将输入传递给脚本的其余部分。

另外快速请求是如果有人可以指导我但不要为我解决问题,这样我可以更好地学习。谢谢你。

from netmiko import ConnectHandler
ipaddr = input('Type IP:')

device(I've tried net_connect also) =  ConnectHandler(ip = 'ipaddr',
                        port = 22,
                        username = 'admin',
                        password = 'mypassword',
                        device_type = 'cisco_wlc_ssh')

net_connect.find_prompt()
'(Cisco Controller) >'
output = net_connect.send_command('show ap summary')
print(output)
net_connect.disconnect()

标签: pythonssh

解决方案


推荐阅读